Exemplo n.º 1
0
/**
 * Display list available specialties.
 */
void view_spec_menu(void)
{
    menu_type menu;
    menu_iter menu_f = { view_spec_tag, 0, view_spec_display, 0, 0 };
    region loc = { 0, 0, 70, -99 };
    char buf[80];

    /* Save the screen and clear it */
    screen_save();

    /* Prompt choices */
    sprintf(buf, "Race, class, and specialties abilities (%c-%c, ESC=exit): ",
	    I2A(0), I2A(spec_known - 1));

    /* Set up the menu */
    menu_init(&menu, MN_SKIN_SCROLL, &menu_f);
    menu.header = buf;
    menu_setpriv(&menu, spec_known, spec_list);
    loc.page_rows = spec_known + 1;
    menu.flags = MN_DBL_TAP;
    menu.browse_hook = view_spec_menu_browser;
    region_erase_bordered(&loc);
    menu_layout(&menu, &loc);

    menu_select(&menu, 0);

    /* Load screen */
    screen_load();

    return;
}
Exemplo n.º 2
0
static void _list_spells(doc_ptr doc, int options)
{
    int i;

    doc_insert(doc, "<style:table>");
    doc_printf(doc, "<color:G>    %-20.20s Lvl  SP Fail %-15.15s", "Name", "Desc");
    if (options & _SHOW_STATS)
        doc_insert(doc, "  Cast Fail");
    doc_insert(doc, "</color>\n");

    for (i = 0; i < _MAX_SLOTS; i++)
    {
        if (_spells[i].realm != REALM_NONE)
            _list_spell(doc, _spells[i].realm, _spells[i].spell, i, options);
        else
        {
            if (options & _ALLOW_EMPTY)
                doc_printf(doc, " %c) <color:D>(Empty)</color>\n", I2A(i));
            else
                doc_printf(doc, " <color:D>%c) (Empty)</color>\n", I2A(i));
        }
    }
    doc_insert(doc, "</style>");

    if (_browse_choice != -1 && _spells[_browse_choice].realm != REALM_NONE)
    {
        doc_newline(doc);
        doc_printf(doc, "    <indent>%s</indent>\n\n",
            do_spell(_spells[_browse_choice].realm, _spells[_browse_choice].spell, SPELL_DESC));
    }
}
Exemplo n.º 3
0
/**
 * Convert a gear object into a one character label.
 */
char gear_to_label(struct object *obj)
{
	int i;

	/* Equipment is easy */
	if (object_is_equipped(player->body, obj)) {
		return I2A(equipped_item_slot(player->body, obj));
	}

	/* Check the quiver */
	for (i = 0; i < z_info->quiver_size; i++) {
		if (player->upkeep->quiver[i] == obj) {
			return I2D(i);
		}
	}

	/* Check the inventory */
	for (i = 0; i < z_info->pack_size; i++) {
		if (player->upkeep->inven[i] == obj) {
			return I2A(i);
		}
	}

	return '\0';
}
Exemplo n.º 4
0
static int _choose_mimic_form(void)
{
    int             r_idx = -1;
    int             i;
    _choice_array_t choices = {{{0}}};

    /* List Known Forms */
    for (i = 0; i < _MAX_FORMS; i++)
    {
        if (_forms[i])
        {
            int        j = choices.size++;
            _choice_t *choice = &choices.choices[j];

            choice->r_idx = _forms[i];
            choice->slot = i;
            choice->type = _TYPE_KNOWN;
            choice->key = I2A(j);
        }
    }

    /* List Visible Forms */
    for (i = 1; i < m_max; i++)
    {
        monster_type *m_ptr = &m_list[i];

        if (!m_ptr->r_idx) continue;
        if (!m_ptr->ml) continue;
        if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) continue;
        if (!r_info[m_ptr->r_idx].body.life) continue; /* Form not implemented yet ... */

        _add_visible_form(&choices, m_ptr->r_idx);
    }

    /* Assign menu keys at the end due to insertion sort */
    for (i = 0; i < choices.size; i++)
    {
        _choice_t *choice = &choices.choices[i];
        
        if (choice->type == _TYPE_VISIBLE)
            choice->key = I2A(i);
    }

    if (choices.size)
    {
        choices.mode = _CHOOSE_MODE_MIMIC;
        if (_choose(&choices))
            r_idx = choices.choices[choices.current].r_idx;
        do_cmd_redraw();
    }
    else
        msg_print("You see nothing to mimic.");
    return r_idx;
}
Exemplo n.º 5
0
static void _list_spell(doc_ptr doc, int realm, int spell, int choice, int options)
{
    magic_type *spell_ptr = _get_spell_info(realm, spell);
    int         cost = calculate_cost(spell_ptr->smana);
    int         fail = calculate_fail_rate(spell_ptr->slevel, spell_ptr->sfail, p_ptr->stat_ind[A_INT]);

    if (cost > p_ptr->csp)
        doc_insert(doc, "<color:D>");
    else if (choice == _browse_choice)
        doc_insert(doc, "<color:B>");
    else if (spell_ptr->slevel > p_ptr->lev)
    {
        if (options & _FROM_BOOK)
            doc_insert(doc, "<color:D>");
        else
            doc_insert(doc, "<color:y>");
    }
    else
        doc_insert(doc, "<color:w>");

    if (spell_ptr->slevel > p_ptr->lev)
        doc_printf(doc, " <color:D>%c)</color> ", I2A(choice));
    else
        doc_printf(doc, " %c) ", I2A(choice));

    doc_printf(doc, "%-20.20s ", do_spell(realm, spell, SPELL_NAME));
    doc_printf(doc, "%3d %3d %3d%% ", spell_ptr->slevel, cost, fail);

    if (spell_ptr->slevel > p_ptr->lev)
    {
        if (options & _FROM_BOOK)
            doc_printf(doc, "%-15.15s", "");
        else
            doc_printf(doc, "%-15.15s", "Forgotten");
    }
    else if (options & _SHOW_INFO)
        doc_printf(doc, "%-15.15s", do_spell(realm, spell, SPELL_INFO));

    if (options & _SHOW_STATS)
    {
        spell_stats_ptr stats = spell_stats_old(realm, spell);
        if (stats->ct_cast + stats->ct_fail)
        {
            doc_printf(doc, " %5d %4d %3d%%",
                stats->ct_cast,
                stats->ct_fail,
                spell_stats_fail(stats)
            );
        }
    }

    doc_insert(doc, "</color>\n");
}
Exemplo n.º 6
0
/**
 * Melee effect handler: Eat the player's food.
 */
static void melee_effect_handler_EAT_FOOD(melee_effect_handler_context_t *context)
{
	/* Steal some food */
	int tries;

	/* Take damage */
	take_hit(context->p, context->damage, context->ddesc);

	/* Player is dead */
	if (context->p->is_dead)
		return;

	for (tries = 0; tries < 10; tries++) {
		/* Pick an item from the pack */
		int index = randint0(z_info->pack_size);
		struct object *obj, *eaten;
		char o_name[80];
		bool none_left = false;

		/* Get the item */
		obj = context->p->upkeep->inven[index];

		/* Skip non-objects */
		if (obj == NULL) continue;

		/* Skip non-food objects */
		if (!tval_is_edible(obj)) continue;

		if (obj->number == 1) {
			object_desc(o_name, sizeof(o_name), obj, ODESC_BASE);
			msg("Your %s (%c) was eaten!", o_name, I2A(index));
		} else {
			object_desc(o_name, sizeof(o_name), obj,
						ODESC_PREFIX | ODESC_BASE);
			msg("One of your %s (%c) was eaten!", o_name,
				I2A(index));
		}

		/* Steal and eat */
		eaten = gear_object_for_use(obj, 1, false, &none_left);
		if (eaten->known)
			object_delete(&eaten->known);
		object_delete(&eaten);

		/* Obvious */
		context->obvious = true;

		/* Done */
		break;
	}
}
Exemplo n.º 7
0
/**
 * Overflow an item from the pack, if it is overfull.
 */
void pack_overflow(void)
{
	int i;
	struct object *obj = NULL;
	char o_name[80];

	if (!pack_is_overfull()) return;

	/* Disturbing */
	disturb(player, 0);

	/* Warning */
	msg("Your pack overflows!");

	/* Find the last inventory item */
	for (i = 1; i <= z_info->pack_size; i++)
		if (!player->upkeep->inven[i])
			break;

	/* Last object was the previous index */
	obj = player->upkeep->inven[i - 1];

	/* Rule out weirdness (like pack full, but inventory empty) */
	assert(obj != NULL);

	/* Describe */
	object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL);

	/* Message */
	msg("You drop %s (%c).", o_name, I2A(i - 1));

	/* Excise the object and drop it (carefully) near the player */
	gear_excise_object(obj);
	drop_near(cave, obj, 0, player->py, player->px, FALSE);

	/* Describe */
	if (obj->artifact)
		msg("You no longer have the %s (%c).", o_name, I2A(i - 1));
	else
		msg("You no longer have %s (%c).", o_name, I2A(i - 1));

	/* Notice stuff (if needed) */
	if (player->upkeep->notice) notice_stuff(player->upkeep);

	/* Update stuff (if needed) */
	if (player->upkeep->update) update_stuff(player->upkeep);

	/* Redraw stuff (if needed) */
	if (player->upkeep->redraw) redraw_stuff(player->upkeep);
}
Exemplo n.º 8
0
/**
 * Take off a non-cursed equipment item
 *
 * Note that taking off an item when "full" may cause that item
 * to fall to the ground.
 *
 * Note also that this function does not try to combine the taken off item
 * with other inventory items - that must be done by the calling function.
 */
void inven_takeoff(struct object *obj)
{
	int slot = equipped_item_slot(player->body, obj);
	const char *act;
	char o_name[80];

	/* Paranoia */
	if (slot == player->body.count) return;

	/* Describe the object */
	object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL);

	/* Describe removal by slot */
	if (slot_type_is(slot, EQUIP_WEAPON))
		act = "You were wielding";
	else if (slot_type_is(slot, EQUIP_BOW))
		act = "You were holding";
	else if (slot_type_is(slot, EQUIP_LIGHT))
		act = "You were holding";
	else
		act = "You were wearing";

	/* De-equip the object */
	player->body.slots[slot].obj = NULL;
	player->upkeep->equip_cnt--;

	/* Message */
	msgt(MSG_WIELD, "%s %s (%c).", act, o_name, I2A(slot));

	player->upkeep->update |= (PU_BONUS | PU_INVEN);
	player->upkeep->notice |= (PN_IGNORE);
	return;
}
Exemplo n.º 9
0
/*
 * Buy items from the current shop
 */
static void borg_think_shop_buy(int item)
{
	list_item *l_ptr = &cur_list[item];

	/* Is the borg on page 1 but wants to be one page 2? */
	if ((borg_term_text_comp(26, 5, "1") && item >= STORE_INVEN_MAX / 2) ||
		(borg_term_text_comp(26, 5, "2") && item <  STORE_INVEN_MAX / 2))
	{
		/* Goto the other page */
		borg_keypress(' ');
	}

	/* Log */
	borg_note("# Buying %s (%i gold).", l_ptr->o_name, l_ptr->cost);

	/* Buy one item */
	borg_keypress('0');
	borg_keypress('1');

	/* Buy an item */
	borg_keypress('p');

	/* Buy the desired item */
	borg_keypress(I2A(item % (STORE_INVEN_MAX / 2)));

	/* Increment 'use' count */
	borg_shops[shop_num].u_count++;

	/* The purchase is complete */
	goal_shop = -1;
}
Exemplo n.º 10
0
int altel6045_get_dt_data(const hwextisp_intf_t *i, struct device_node *of_node)
{
	int ret = 0;
	int index = 0;
	altek6045_private_data_t* pdata = NULL;
	altek6045_t* mini_isp = NULL;
	
	mini_isp = I2A(i);
	pdata = (altek6045_private_data_t *)mini_isp->pdata;

	ret = of_property_read_u32_array(of_node, "hisi,isp-pin",
		pdata->pin, ISP_MAX);
	if (ret < 0) {
		cam_err("%s failed line %d\n", __func__, __LINE__);
		return ret;
	} else {
		for (index = 0; index < ISP_MAX; index++) {
			cam_debug("%s pin[%d]=%d.\n", __func__, index,
				pdata->pin[index]);
		}
	}
#if 0
    ret = gpio_request(pdata->pin[ISP_DVDD], "isp-dcdc");
    if (ret < 0) {
        cam_err("%s failed to request isp-dvdd pin.", __func__);
        return ret;
    }
#endif
	return ret; 
}
Exemplo n.º 11
0
/*! 
 * @brief スナイパーの技能リストを表示する
 * @return なし
 */
void display_snipe_list(void)
{
	int             i;
	int             y = 1;
	int             x = 1;
	int             plev = p_ptr->lev;
	snipe_power     spell;
	char            psi_desc[80];

	/* Display a list of spells */
	prt("", y, x);
#ifdef JP
	put_str("名前", y, x + 5);
	put_str("Lv   MP", y, x + 35);
#else
	put_str("Name", y, x + 5);
	put_str("Lv Mana", y, x + 35);
#endif

	/* Dump the spells */
	for (i = 0; i < MAX_SNIPE_POWERS; i++)
	{
		/* Access the available spell */
		spell = snipe_powers[i];
		if (spell.min_lev > plev) continue;
		if (spell.mana_cost > (int)p_ptr->concent) continue;

		/* Dump the spell */
		sprintf(psi_desc, "  %c) %-30s%2d %4d",
			I2A(i), spell.name, spell.min_lev, spell.mana_cost);

		Term_putstr(x, y + i + 1, -1, TERM_WHITE, psi_desc);
	}
	return;
}
Exemplo n.º 12
0
int altek6045_power_off(const hwextisp_intf_t* i)
{
	return misp_exit();
#if 0
    altek6045_private_data_t* pdata = NULL;
    altek6045_t* mini_isp = NULL;

    cam_notice("enter %s.", __func__);
    mini_isp = I2A(i);
    pdata = (altek6045_private_data_t *)mini_isp->pdata;

    if (ncp6925_ctrl.func_tbl->pmic_seq_config) {
	ret = ncp6925_ctrl.func_tbl->pmic_seq_config(&ncp6925_ctrl, VOUT_LDO_4, VOLTAGE_1P8V, MINI_ISP_POWER_OFF);
    }

    udelay(5);

    if (ncp6925_ctrl.func_tbl->pmic_seq_config) {
	ret = ncp6925_ctrl.func_tbl->pmic_seq_config(&ncp6925_ctrl, VOUT_LDO_5, VOLTAGE_1P1V, MINI_ISP_POWER_OFF);
    }

    udelay(5);

    gpio_direction_output(pdata->pin[ISP_DVDD], MINI_ISP_POWER_OFF);

    msleep(2);
#endif
}
Exemplo n.º 13
0
STATICFNDEF int4 update_trigger_name_value(int trigvn_len, char *trig_name, int trig_name_len, int new_trig_index)
{
	sgmnt_addrs		*csa;
	mname_entry		gvent;
	gv_namehead		*hasht_tree;
	int			len;
	char			name_and_index[MAX_MIDENT_LEN + 1 + MAX_DIGITS_IN_INT];
	char			new_trig_name[MAX_TRIGNAME_LEN + 1];
	int			num_len;
	char			*ptr;
	int4			result;
	char			save_currkey[SIZEOF(gv_key) + DBKEYSIZE(MAX_KEY_SZ)];
	gv_key			*save_gv_currkey;
	gd_region		*save_gv_cur_region;
	gv_namehead		*save_gv_target;
	sgm_info		*save_sgm_info_ptr;
	mval			trig_gbl;
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	if (MAX_AUTO_TRIGNAME_LEN < trigvn_len)
		return PUT_SUCCESS;
	SAVE_TRIGGER_REGION_INFO;
	SWITCH_TO_DEFAULT_REGION;
	if (gv_cur_region->read_only)
		rts_error_csa(CSA_ARG(csa) VARLSTCNT(4) ERR_TRIGMODREGNOTRW, 2, REG_LEN_STR(gv_cur_region));
	assert(0 != gv_target->root);
	/* $get(^#t("#TNAME",^#t(GVN,index,"#TRIGNAME")) */
	BUILD_HASHT_SUB_SUB_CURRKEY(LITERAL_HASHTNAME, STRLEN(LITERAL_HASHTNAME), trig_name, trig_name_len - 1);
	if (!gvcst_get(&trig_gbl))
	{	/* There has to be a #TNAME entry */
		if (CDB_STAGNATE > t_tries)
			t_retry(cdb_sc_triggermod);
		else
		{
			assert(WBTEST_HELPOUT_TRIGDEFBAD == gtm_white_box_test_case_number);
			rts_error_csa(CSA_ARG(NULL) VARLSTCNT(6) ERR_TRIGNAMBAD, 4, LEN_AND_LIT("\"#TNAME\""), trig_name_len - 1,
					trig_name);
		}
	}
	len = STRLEN(trig_gbl.str.addr) + 1;
	assert(MAX_MIDENT_LEN >= len);
	memcpy(name_and_index, trig_gbl.str.addr, len);
	ptr = name_and_index + len;
	num_len = 0;
	I2A(ptr, num_len, new_trig_index);
	len += num_len;
	/* set ^#t(GVN,index,"#TRIGNAME")=trig_name $C(0) new_trig_index */
	SET_TRIGGER_GLOBAL_SUB_SUB_STR(LITERAL_HASHTNAME, STRLEN(LITERAL_HASHTNAME), trig_name, trig_name_len - 1,
		name_and_index, len, result);
	RESTORE_TRIGGER_REGION_INFO;
	return result;
}
Exemplo n.º 14
0
/* How to handle the enchant armour building */
static bool borg_build_armour(void)
{
	int i, slot = -1;
	list_item *l_ptr;

	/* Does the borg have enough gold? */
	if (borg_gold < 2000) return (FALSE);

	for (i = EQUIP_BODY; i < equip_num; i++)
	{
		l_ptr = look_up_equip_slot(i);

		/* Is there armour here? */
		if (!l_ptr) continue;

		/* Is there improvement for the to_hit and to_dam bonus */
		if (l_ptr->to_a >= bp_ptr->lev / 5) continue;

		/* Found an armour */
		slot = i;

		break;
	}

	/* Was an armour found? */
	if (slot == -1) return (FALSE);

	/* Let's go for it */
	borg_keypress('E');

	/* Find out if there are armour in the inv */
	for (i = 0; i < inven_num; i++)
	{
		l_ptr = &inventory[i];

		if (l_ptr->tval >= TV_BOOTS && l_ptr->tval <= TV_DRAG_ARMOR)
		{
			/* skip the inv and go to equip */
			borg_keypress('/');

			break;
		}
	}

	/* And enchant the armour */
	borg_keypress(I2A(slot));

	/* Say so */
	borg_note("# Enchanting %s at the magesmith.", l_ptr->o_name);

	return (TRUE);
}
Exemplo n.º 15
0
/**
 * Show quiver missiles in full inventory
 */
static void item_menu_browser(int oid, void *data, const region *local_area)
{
	char tmp_val[80];
	int count, j, i = num_obj;
	int quiver_slots = (player->upkeep->quiver_cnt + z_info->quiver_slot_size - 1)
		/ z_info->quiver_slot_size;

	/* Set up to output below the menu */
	text_out_hook = text_out_to_screen;
	text_out_wrap = 0;
	text_out_indent = local_area->col - 1;
	text_out_pad = 1;
	prt("", local_area->row + local_area->page_rows, MAX(0, local_area->col - 1));
	Term_gotoxy(local_area->col, local_area->row + local_area->page_rows);

	/* If we're printing pack slots the quiver takes up */
	if (olist_mode & OLIST_QUIVER && player->upkeep->command_wrk == USE_INVEN) {
		/* Quiver may take multiple lines */
		for (j = 0; j < quiver_slots; j++, i++) {
			const char *fmt = "in Quiver: %d missile%s\n";
			char letter = I2A(i);

			/* Number of missiles in this "slot" */
			if (j == quiver_slots - 1)
				count = player->upkeep->quiver_cnt - (z_info->quiver_slot_size *
													  (quiver_slots - 1));
			else
				count = z_info->quiver_slot_size;

			/* Print the (disabled) label */
			strnfmt(tmp_val, sizeof(tmp_val), "%c) ", letter);
			text_out_c(COLOUR_SLATE, tmp_val, local_area->row + i, local_area->col);

			/* Print the count */
			strnfmt(tmp_val, sizeof(tmp_val), fmt, count,
					count == 1 ? "" : "s");
			text_out_c(COLOUR_L_UMBER, tmp_val, local_area->row + i, local_area->col + 3);
		}
	}

	/* Always print a blank line */
	prt("", local_area->row + i, MAX(0, local_area->col - 1));

	/* Blank out whole tiles */
	while ((tile_height > 1) && ((local_area->row + i) % tile_height != 0)) {
		i++;
		prt("", local_area->row + i, MAX(0, local_area->col - 1));
	}

	text_out_pad = 0;
	text_out_indent = 0;
}
Exemplo n.º 16
0
/*
 * Print a batch of skills.
 */
static void print_skill_batch(int *p, cptr *p_desc, int start, int max, bool mode)
{
	char buff[80];
	int i = start, j = 0;

	if (mode) prt(format("         %-31s", "Name"), 1, 20);

	for (i = start; i < (start + 20); i++)
	{
		if (i >= max) break;

		if (p[i] > 0)
			sprintf(buff, "  %c - %d) %-30s", I2A(j), p[i], p_desc[i]);
		else
			sprintf(buff, "  %c - %d) %-30s", I2A(j), p[i], "Change melee style");

		if (mode) prt(buff, 2 + j, 20);
		j++;
	}
	if (mode) prt("", 2 + j, 20);
	prt(format("Select a skill (a-%c), @ to select by name, +/- to scroll:", I2A(j - 1)), 0, 0);
}
Exemplo n.º 17
0
static void _list(menu_ptr menu, char *keys)
{
    char temp[255];
    int  i;
    int  y = 1;
    int  x = 13;

    Term_erase(x, y, 255);

    if (menu->heading)
        put_str(format("     %s", menu->heading), y++, x);

    for (i = 0; i < menu->count; i++)
    {
        byte attr = TERM_WHITE;
        variant key, text, color;

        var_init(&key);
        var_init(&text);
        var_init(&color);

        menu->fn(MENU_KEY, i, menu->cookie, &key);
        if (var_is_null(&key))
            keys[i] = I2A(i);
        else
            keys[i] = (char)var_get_int(&key);

        if (menu->count <= 26)
            keys[i] = tolower(keys[i]);

        menu->fn(MENU_TEXT, i, menu->cookie, &text);
        if (var_is_null(&text))
            var_set_string(&text, "");

        menu->fn(MENU_COLOR, i, menu->cookie, &color);
        if (!var_is_null(&color))
            attr = var_get_int(&color);

        if (attr == TERM_DARK)
            keys[i] = '\0';

        sprintf(temp, "  %c) %s", keys[i], var_get_string(&text));
        c_prt(attr, temp, y + i, x);

        var_clear(&key);
        var_clear(&text);
        var_clear(&color);
    }
    Term_erase(x, y + menu->count, 255);
}
Exemplo n.º 18
0
/**
 * Build the object list.
 */
static void build_obj_list(int last, struct object **list, item_tester tester,
						   olist_detail_t mode)
{
	int i;
	bool gold_ok = (mode & OLIST_GOLD) ? true : false;
	bool in_term = (mode & OLIST_WINDOW) ? true : false;
	bool dead = (mode & OLIST_DEATH) ? true : false;
	bool show_empty = (mode & OLIST_SEMPTY) ? true : false;
	bool equip = list ? false : true;
	bool quiver = list == player->upkeep->quiver ? true : false;

	/* Build the object list */
	for (i = 0; i <= last; i++) {
		char buf[80];
		struct object *obj = equip ? slot_object(player, i) : list[i];

		/* Acceptable items get a label */
		if (object_test(tester, obj) ||	(obj && tval_is_money(obj) && gold_ok))
			strnfmt(items[num_obj].label, sizeof(items[num_obj].label), "%c) ",
					quiver ? I2D(i) : I2A(i));

		/* Unacceptable items are still sometimes shown */
		else if ((!obj && show_empty) || in_term)
			my_strcpy(items[num_obj].label, "   ",
					  sizeof(items[num_obj].label));

		/* Unacceptable items are skipped in the main window */
		else continue;

		/* Show full slot labels for equipment (or quiver in subwindow) */
		if (equip) {
			strnfmt(buf, sizeof(buf), "%-14s: ", equip_mention(player, i));
			my_strcpy(items[num_obj].equip_label, buf,
					  sizeof(items[num_obj].equip_label));
		} else if ((in_term || dead) && quiver) {
			strnfmt(buf, sizeof(buf), "Slot %-9d: ", i);
			my_strcpy(items[num_obj].equip_label, buf,
					  sizeof(items[num_obj].equip_label));
		} else {
			strnfmt(items[num_obj].equip_label,
					sizeof(items[num_obj].equip_label), "");
		}

		/* Save the object */
		items[num_obj].object = obj;
		items[num_obj].key = (items[num_obj].label)[0];
		num_obj++;
	}
}
Exemplo n.º 19
0
Arquivo: powers.c Projeto: jcubic/ToME
/*
 * Print a batch of power.
 */
static void print_power_batch(s32b *p, s32b start, s32b max, bool mode)
{
	char buff[80];
	power_type* spell;
	s32b i = start, j = 0;

	if (mode) prt(format("         %-31s Level Mana Fail", "Name"), 1, 20);

	for (i = start; i < (start + 20); i++)
	{
		if (i >= max) break;

		spell = &powers_type[p[i]];

		sprintf(buff, "  %c-%3ld) %-30s  %5d %4d %s@%d", (char) I2A(j),
				p[i] + 1, spell->name,
		        spell->level, spell->cost, stat_names[spell->stat], spell->diff);

		if (mode) prt(buff, 2 + j, 20);
		j++;
	}
	if (mode) prt("", 2 + j, 20);
	prt(format("Select a power (a-%c), +/- to scroll:", I2A(j - 1)), 0, 0);
}
Exemplo n.º 20
0
/*
 * Sell items to the current shop
 */
static void borg_think_shop_sell(int item, list_item *l_ptr)
{
	/* Log */
	borg_note("# Selling %s (%c)", l_ptr->o_name, I2A(item));

	/* One item */
	borg_keypress('0');
	borg_keypress('1');

	/* Sell an item */
	borg_keypress('s');

	/* Sell the desired item */
	borg_keypress(I2A(item));

	/* If the user likes this option */
	if (check_transaction) borg_keypress('y');

	/* Increment 'use' count */
	borg_shops[shop_num].u_count++;

	/* The purchase is complete */
	goal_shop = -1;
}
Exemplo n.º 21
0
STATICFNDEF int4 update_trigger_name_value(char *trig_name, int trig_name_len, int new_trig_index)
{
	int			len;
	char			name_and_index[MAX_MIDENT_LEN + 1 + MAX_DIGITS_IN_INT];
	int			num_len;
	char			*ptr;
	int4			result;
	mval			trig_gbl;
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	assert(!gv_cur_region->read_only);		/* caller should have already checked this */
	assert(cs_addrs->hasht_tree == gv_target);	/* should have been set up by caller */
	assert(gv_target->root);			/* should have been ensured by caller */
	/* $get(^#t("#TNAME",^#t(GVN,index,"#TRIGNAME"))) */
	BUILD_HASHT_SUB_SUB_CURRKEY(LITERAL_HASHTNAME, STRLEN(LITERAL_HASHTNAME), trig_name, trig_name_len - 1);
	if (!gvcst_get(&trig_gbl))
	{	/* There has to be a #TNAME entry */
		if (CDB_STAGNATE > t_tries)
			t_retry(cdb_sc_triggermod);
		assert(WBTEST_HELPOUT_TRIGDEFBAD == gtm_white_box_test_case_number);
		rts_error_csa(CSA_ARG(NULL) VARLSTCNT(6) ERR_TRIGNAMBAD, 4, LEN_AND_LIT("\"#TNAME\""),
			trig_name_len - 1, trig_name);
	}
	ptr = trig_gbl.str.addr;
	len = MIN(trig_gbl.str.len, MAX_MIDENT_LEN);
	STRNLEN(ptr, len, len);
	ptr += len;
	if ((trig_gbl.str.len == len) || ('\0' != *ptr))
	{
		if (CDB_STAGNATE > t_tries)
			t_retry(cdb_sc_triggermod);
		assert(WBTEST_HELPOUT_TRIGDEFBAD == gtm_white_box_test_case_number);
		rts_error_csa(CSA_ARG(NULL) VARLSTCNT(6) ERR_TRIGNAMBAD, 4, LEN_AND_LIT("\"#TNAME\""),
			trig_name_len - 1, trig_name);
	}
	memcpy(name_and_index, trig_gbl.str.addr, ++len); /* inline increment intended */
	ptr = name_and_index + len;
	num_len = 0;
	I2A(ptr, num_len, new_trig_index);
	len += num_len;
	/* set ^#t("#TNAME",<trigname>)=gblname_$C(0)_new_trig_index */
	SET_TRIGGER_GLOBAL_SUB_SUB_STR(LITERAL_HASHTNAME, STRLEN(LITERAL_HASHTNAME), trig_name, trig_name_len - 1,
		name_and_index, len, result);
	return result;
}
Exemplo n.º 22
0
/* Set ^#t(<gbl>,"#TRHASH",hash_code,nnn)=<gbl>_$c(0)_trigindx where gv_currkey is ^#t(<gbl>).
 * Note: This routine has code very similar to that in "add_trigger_hash_entry". There is just
 * not enough commonality to justify merging the two.
 */
STATICFNDEF void	gvtr_set_hashtrhash(char *trigvn, int trigvn_len, uint4 hash_code, int trigindx)
{
	uint4		curend;
	mval		mv_indx, *mv_indx_ptr;
	mval		mv_hash;
	int		hash_indx, num_len;
	char		name_and_index[MAX_MIDENT_LEN + 1 + MAX_DIGITS_IN_INT];
	char		*ptr;
	char		indx_str[MAX_DIGITS_IN_INT];
	uint4		len;
	int4		result;
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	curend = gv_currkey->end; /* note down gv_currkey->end before changing it so we can restore it before function returns */
	assert(KEY_DELIMITER == gv_currkey->base[curend]);
	assert(gv_target->gd_csa == cs_addrs);
	/* Set ^#t(<gvn>,"#TRHASH",kill_hash_code,i). To do that, first determine the
	 * highest i such that ^#t(<gvn>,"#TRHASH",kill_hash_code,i) exists. Set
	 * ^#t(<gvn>,"#TRHASH",kill_hash_code,i+1)=kill_hash_code in that case.
	 */
	MV_FORCE_UMVAL(&mv_hash, hash_code);
	BUILD_HASHT_SUB_SUB_MSUB_SUB_CURRKEY(trigvn, trigvn_len, LITERAL_HASHTRHASH, STRLEN(LITERAL_HASHTRHASH), mv_hash, "", 0);
	op_zprevious(&mv_indx);
	mv_indx_ptr = &mv_indx;
	hash_indx = (0 == mv_indx.str.len) ? 1 : (mval2i(mv_indx_ptr) + 1);
	i2mval(mv_indx_ptr, hash_indx);
	MV_FORCE_STR(mv_indx_ptr);
	/* Prepare the value of the SET */
	num_len = 0;
	I2A(indx_str, num_len, trigindx);
	assert(MAX_MIDENT_LEN >= trigvn_len);
	memcpy(name_and_index, trigvn, trigvn_len);
	ptr = name_and_index + trigvn_len;
	*ptr++ = '\0';
	memcpy(ptr, indx_str, num_len);
	len = trigvn_len + 1 + num_len;
	/* Do the SET */
	SET_TRIGGER_GLOBAL_SUB_SUB_MSUB_MSUB_STR(trigvn, trigvn_len,
		LITERAL_HASHTRHASH, STRLEN(LITERAL_HASHTRHASH), mv_hash, mv_indx, name_and_index, len, result);
	assert(PUT_SUCCESS == result);
	gv_currkey->end = curend;	/* reset gv_currkey->end to what it was at function entry */
	gv_currkey->base[curend] = KEY_DELIMITER;    /* restore terminator for entire key so key is well-formed */
	return;
}
Exemplo n.º 23
0
static char tag_options_item(struct menu *menu, int oid)
{
	size_t line = (size_t) oid;

	if (line < N_ELEMENTS(sval_dependent))
		return I2A(oid);

	/* Separator - blank line. */
	if (line == N_ELEMENTS(sval_dependent))
		return 0;

	line = line - N_ELEMENTS(sval_dependent) - 1;

	if (line < N_ELEMENTS(extra_item_options))
		return extra_item_options[line].tag;

	return 0;
}
Exemplo n.º 24
0
int altek6045_power_on(const hwextisp_intf_t* i)
{
    int ret = 0;
    misp_init();
#if 0
    altek6045_private_data_t* pdata = NULL;
    altek6045_t* mini_isp = NULL;
	
    cam_notice("enter %s.", __func__);
    mini_isp = I2A(i);
    pdata = (altek6045_private_data_t *)mini_isp->pdata;

    /* step1 pull up gpio20 to enable dcdc 1.1v for miniisp */
    //todo...
    // for udp, gpio20 to gpio21
    gpio_direction_output(pdata->pin[ISP_DVDD], MINI_ISP_POWER_ON);

    udelay(5);

    /* step2 open pmic ldo5 1.1v for minisip */
    //todo...
    if (ncp6925_ctrl.func_tbl->pmic_seq_config) {
	ret = ncp6925_ctrl.func_tbl->pmic_seq_config(&ncp6925_ctrl, VOUT_LDO_5, VOLTAGE_1P1V, MINI_ISP_POWER_ON);
    }

    udelay(5);

    /* step3 open pmic ldo4 1.8v for minisip */
    //todo...
    if (ncp6925_ctrl.func_tbl->pmic_seq_config) {
	ret = ncp6925_ctrl.func_tbl->pmic_seq_config(&ncp6925_ctrl, VOUT_LDO_4, VOLTAGE_1P8V, MINI_ISP_POWER_ON);
    }

    msleep(2);

    /* step4 reset miniisp */
    //todo...

    /* step5 load miniisp fw */
    //todo...
#endif
    return ret;
}
Exemplo n.º 25
0
static int _choose_new_slot(int new_r_idx)
{
    int             slot = -1;
    int             i;
    _choice_array_t choices = {{{0}}};

    /* Display the Newly Learned Form */
    assert(new_r_idx);
    {
        _choice_t *choice = &choices.choices[choices.size++];
        choice->r_idx = new_r_idx;
        choice->slot = -1; /* paranoia ... it should not be possible to choose this choice! */
        choice->type = _TYPE_NEW;
    }

    /* List Existing Slots/Known Forms */
    for (i = 0; i < _MAX_FORMS; i++)
    {
        if (_forms[i])
        {
            int        j = choices.size++;
            _choice_t *choice = &choices.choices[j];
            choice->r_idx = _forms[i];
            choice->slot = i;
            choice->type = _TYPE_KNOWN;
            choice->key = I2A(j-1);
        }
        else
        {
            /* Simply use the first empty slot */
            return i;
        }
    }

    choices.mode = _CHOOSE_MODE_LEARN;
    if (_choose(&choices))
        slot = choices.choices[choices.current].slot;
    do_cmd_redraw();

    return slot;
}
Exemplo n.º 26
0
/**
 * Show quiver missiles in full inventory
 */
static void item_menu_browser(int oid, void *data, const region *area)
{
	char tmp_val[80];
	int count, j, i = num_obj;
	int quiver_slots = (player->upkeep->quiver_cnt + z_info->stack_size - 1)
		/ z_info->stack_size;

	/* Set up to output below the menu */
	text_out_hook = text_out_to_screen;
	text_out_wrap = 0;
	text_out_indent = area->col - 1;
	text_out_pad = 1;
	prt("", area->row + area->page_rows, MAX(0, area->col - 1));
	Term_gotoxy(area->col, area->row + area->page_rows);

	/* Quiver may take multiple lines */
	for (j = 0; j < quiver_slots; j++, i++) {
		const char *fmt = "in Quiver: %d missile%s\n";
		char letter = I2A(i);

		/* Number of missiles in this "slot" */
		if (j == quiver_slots - 1)
			count = player->upkeep->quiver_cnt - (z_info->stack_size *
													  (quiver_slots - 1));
		else
			count = z_info->stack_size;

		/* Print the (disabled) label */
		strnfmt(tmp_val, sizeof(tmp_val), "%c) ", letter);
		text_out_c(COLOUR_SLATE, tmp_val, area->row + i, area->col);

		/* Print the count */
		strnfmt(tmp_val, sizeof(tmp_val), fmt, count,
				count == 1 ? "" : "s");
		text_out_c(COLOUR_L_UMBER, tmp_val, area->row + i, area->col + 3);
	}

	text_out_pad = 0;
	text_out_indent = 0;
}
Exemplo n.º 27
0
static void dump_modules(int sel, int max)
{
	int i;

	char buf[40], pre = ' ', post = ')';
	cptr name;

	char ind;


	for (i = 0; i < max; i++)
	{
		ind = I2A(i % 26);
		if (i >= 26) ind = toupper(ind);

		if (sel == i)
		{
			pre = '[';
			post = ']';
		}
		else
		{
			pre = ' ';
			post = ')';
		}

		call_lua("get_module_name", "(d)", "s", i, &name);
		strnfmt(buf, 40, "%c%c%c %s", pre, ind, post, name);

		if (sel == i)
		{
			call_lua("get_module_desc", "(d)", "s", i, &name);
			print_desc_aux(name, 5, 0);

			c_put_str(TERM_L_BLUE, buf, 10 + (i / 4), 20 * (i % 4));
		}
		else
			put_str(buf, 10 + (i / 4), 20 * (i % 4));
	}
}
Exemplo n.º 28
0
void display_snipe_list(void)
{
    int             i;
    int             y = 1;
    int             x = 1;
    int             plev = p_ptr->lev;
    snipe_power     spell;
    char            desc[80];

    prt("", y, x);
    put_str("Name", y, x + 5);
    put_str("Lv Mana", y, x + 35);

    for (i = 0; i < MAX_SNIPE_POWERS; i++)
    {
        spell = snipe_powers[i];
        if (spell.min_lev > plev) continue;
        if (spell.mana_cost > (int)p_ptr->concent) continue;
        sprintf(desc, "  %c) %-30s%2d %4d",
            I2A(i), spell.name, spell.min_lev, spell.mana_cost);
        Term_putstr(x, y + i + 1, -1, TERM_WHITE, desc);
    }
    return;
}
Exemplo n.º 29
0
/*
 * Menu command: view character dump and inventory.
 */
static void death_info(const char *title, int row)
{
	int i, j, k;
	object_type *o_ptr;
	store_type *st_ptr = &store[STORE_HOME];


	screen_save();

	/* Display player */
	display_player(0);

	/* Prompt for inventory */
	prt("Hit any key to see more information: ", 0, 0);

	/* Allow abort at this point */
	(void)anykey();


	/* Show equipment and inventory */

	/* Equipment -- if any */
	if (p_ptr->equip_cnt)
	{
		Term_clear();
		item_tester_full = TRUE;
		show_equip(OLIST_WEIGHT);
		prt("You are using: -more-", 0, 0);
		(void)anykey();
	}

	/* Inventory -- if any */
	if (p_ptr->inven_cnt)
	{
		Term_clear();
		item_tester_full = TRUE;
		show_inven(OLIST_WEIGHT);
		prt("You are carrying: -more-", 0, 0);
		(void)anykey();
	}



	/* Home -- if anything there */
	if (st_ptr->stock_num)
	{
		/* Display contents of the home */
		for (k = 0, i = 0; i < st_ptr->stock_num; k++)
		{
			/* Clear screen */
			Term_clear();

			/* Show 12 items */
			for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
			{
				byte attr;

				char o_name[80];
				char tmp_val[80];

				/* Get the object */
				o_ptr = &st_ptr->stock[i];

				/* Print header, clear line */
				strnfmt(tmp_val, sizeof(tmp_val), "%c) ", I2A(j));
				prt(tmp_val, j+2, 4);

				/* Get the object description */
				object_desc(o_name, sizeof(o_name), o_ptr,
							ODESC_PREFIX | ODESC_FULL);

				/* Get the inventory color */
				attr = tval_to_attr[o_ptr->tval % N_ELEMENTS(tval_to_attr)];

				/* Display the object */
				c_put_str(attr, o_name, j+2, 7);
			}

			/* Caption */
			prt(format("Your home contains (page %d): -more-", k+1), 0, 0);

			/* Wait for it */
			(void)anykey();
		}
	}

	screen_load();
}
Exemplo n.º 30
0
/**
 * Wield or wear a single item from the pack or floor
 */
void inven_wield(struct object *obj, int slot)
{
	struct object *wielded, *old = player->body.slots[slot].obj;

	const char *fmt;
	char o_name[80];
	bool dummy = false;

	/* Increase equipment counter if empty slot */
	if (old == NULL)
		player->upkeep->equip_cnt++;

	/* Take a turn */
	player->upkeep->energy_use = z_info->move_energy;

	/* It's either a gear object or a floor object */
	if (object_is_carried(player, obj)) {
		/* Split off a new object if necessary */
		if (obj->number > 1) {
			wielded = gear_object_for_use(obj, 1, false, &dummy);

			/* The new item needs new gear and known gear entries */
			wielded->next = obj->next;
			obj->next = wielded;
			wielded->prev = obj;
			if (wielded->next)
				(wielded->next)->prev = wielded;
			wielded->known->next = obj->known->next;
			obj->known->next = wielded->known;
			wielded->known->prev = obj->known;
			if (wielded->known->next)
				(wielded->known->next)->prev = wielded->known;
		} else {
			/* Just use the object directly */
			wielded = obj;
		}
	} else {
		/* Get a floor item and carry it */
		wielded = floor_object_for_use(obj, 1, false, &dummy);
		inven_carry(player, wielded, false, false);
	}

	/* Wear the new stuff */
	player->body.slots[slot].obj = wielded;

	/* Do any ID-on-wield */
	object_learn_on_wield(player, wielded);

	/* Where is the item now */
	if (tval_is_melee_weapon(wielded))
		fmt = "You are wielding %s (%c).";
	else if (wielded->tval == TV_BOW)
		fmt = "You are shooting with %s (%c).";
	else if (tval_is_light(wielded))
		fmt = "Your light source is %s (%c).";
	else
		fmt = "You are wearing %s (%c).";

	/* Describe the result */
	object_desc(o_name, sizeof(o_name), wielded, ODESC_PREFIX | ODESC_FULL);

	/* Message */
	msgt(MSG_WIELD, fmt, o_name, I2A(slot));

	/* Cursed! */
	if (wielded->curses) {
		/* Warn the player */
		msgt(MSG_CURSED, "Oops! It feels deathly cold!");
	}

	/* See if we have to overflow the pack */
	combine_pack();
	pack_overflow(old);

	/* Recalculate bonuses, torch, mana, gear */
	player->upkeep->notice |= (PN_IGNORE);
	player->upkeep->update |= (PU_BONUS | PU_INVEN);
	player->upkeep->redraw |= (PR_INVEN | PR_EQUIP | PR_ARMOR);
	player->upkeep->redraw |= (PR_STATS | PR_HP | PR_MANA | PR_SPEED);

	/* Disable repeats */
	cmd_disable_repeat();
}