Exemple #1
0
bool cheat_parameter::set_next_state()
{
	UINT64 origvalue = m_value;

	// are we a value cheat?
	if (!has_itemlist())
	{
		if (m_value > m_maxval - m_stepval)
			m_value = m_maxval;
		else
			m_value += m_stepval;
	}

	// if not, we're an item cheat
	else
	{
		item *curitem;
		for (curitem = m_itemlist.first(); curitem != NULL; curitem = curitem->next())
			if (curitem->value() == m_value)
				break;
		if (curitem != NULL && curitem->next() != NULL)
			m_value = curitem->next()->value();
	}

	return (m_value != origvalue);
}
Exemple #2
0
bool cheat_parameter::set_next_state()
{
	uint64_t origvalue = m_value;

	// are we a value cheat?
	if (!has_itemlist())
	{
		if (m_value > m_maxval - m_stepval)
			m_value = m_maxval;
		else
			m_value += m_stepval;
	}

	// if not, we're an item cheat
	else
	{
		std::vector<std::unique_ptr<item>>::iterator it;
		for (it = m_itemlist.begin(); it != m_itemlist.end(); ++it)
			if (it->get()->value() == m_value)
				break;
		if (it != m_itemlist.end() && (++it != m_itemlist.end()))
			m_value = it->get()->value();
	}

	return (m_value != origvalue);
}
Exemple #3
0
bool cheat_parameter::set_prev_state()
{
	UINT64 origvalue = m_value;

	// are we a value cheat?
	if (!has_itemlist())
	{
		if (m_value < m_minval + m_stepval)
			m_value = m_minval;
		else
			m_value -= m_stepval;
	}

	// if not, we're an item cheat
	else
	{
		item *curitem, *previtem = NULL;
		for (curitem = m_itemlist.first(); curitem != NULL; previtem = curitem, curitem = curitem->next())
			if (curitem->value() == m_value)
				break;
		if (previtem != NULL)
			m_value = previtem->value();
	}

	return (m_value != origvalue);
}
Exemple #4
0
void cheat_parameter::save(emu_file &cheatfile) const
{
	// output the parameter tag
	cheatfile.printf("\t\t<parameter");

	// if no items, just output min/max/step
	astring string;
	if (!has_itemlist())
	{
		if (m_minval != 0)
			cheatfile.printf(" min=\"%s\"", m_minval.format(string));
		if (m_maxval != 0)
			cheatfile.printf(" max=\"%s\"", m_maxval.format(string));
		if (m_stepval != 1)
			cheatfile.printf(" step=\"%s\"", m_stepval.format(string));
		cheatfile.printf("/>\n");
	}

	// iterate over items
	else
	{
		for (const item *curitem = m_itemlist.first(); curitem != NULL; curitem = curitem->next())
			cheatfile.printf("\t\t\t<item value=\"%s\">%s</item>\n", curitem->value().format(string), curitem->text());
		cheatfile.printf("\t\t</parameter>\n");
	}
}
Exemple #5
0
bool cheat_parameter::set_prev_state()
{
	uint64_t origvalue = m_value;

	// are we a value cheat?
	if (!has_itemlist())
	{
		if (m_value < m_minval + m_stepval)
			m_value = m_minval;
		else
			m_value -= m_stepval;
	}

	// if not, we're an item cheat
	else
	{
		item *previtem = nullptr;
		for (auto &curitem : m_itemlist) {
			if (curitem->value() == m_value)
				break;
			previtem = curitem.get();
		}
		if (previtem != nullptr)
			m_value = previtem->value();
	}

	return (m_value != origvalue);
}
Exemple #6
0
void cheat_parameter::save(emu_file &cheatfile) const
{
	// output the parameter tag
	cheatfile.printf("\t\t<parameter");

	// if no items, just output min/max/step
	if (!has_itemlist())
	{
		if (m_minval != 0)
			cheatfile.printf(" min=\"%s\"", m_minval.format().c_str());
		if (m_maxval != 0)
			cheatfile.printf(" max=\"%s\"", m_maxval.format().c_str());
		if (m_stepval != 1)
			cheatfile.printf(" step=\"%s\"", m_stepval.format().c_str());
		cheatfile.printf("/>\n");
	}

	// iterate over items
	else
	{
		cheatfile.printf(">\n");
		for (auto &curitem : m_itemlist)
			cheatfile.printf("\t\t\t<item value=\"%s\">%s</item>\n", curitem->value().format().c_str(), curitem->text());
		cheatfile.printf("\t\t</parameter>\n");
	}
}
Exemple #7
0
bool cheat_parameter::set_minimum_state()
{
	UINT64 origvalue = m_value;

	// set based on whether we have an item list
	m_value = (!has_itemlist()) ? m_minval : m_itemlist.first()->value();

	return (m_value != origvalue);
}
Exemple #8
0
const char *cheat_parameter::text()
{
	// are we a value cheat?
	if (!has_itemlist())
		m_curtext.format("%d (0x%X)", UINT32(m_value), UINT32(m_value));

	// if not, we're an item cheat
	else
	{
		m_curtext.format("??? (%d)", UINT32(m_value));
		for (item *curitem = m_itemlist.first(); curitem != NULL; curitem = curitem->next())
			if (curitem->value() == m_value)
			{
				m_curtext.cpy(curitem->text());
				break;
			}
	}
	return m_curtext;
}
Exemple #9
0
const char *cheat_parameter::text()
{
	// are we a value cheat?
	if (!has_itemlist())
		strprintf(m_curtext,"%d (0x%X)", UINT32(m_value), UINT32(m_value));

	// if not, we're an item cheat
	else
	{
		strprintf(m_curtext, "??? (%d)", UINT32(m_value));
		for (item *curitem = m_itemlist.first(); curitem != nullptr; curitem = curitem->next())
			if (curitem->value() == m_value)
			{
				m_curtext.assign(curitem->text());
				break;
			}
	}
	return m_curtext.c_str();
}
Exemple #10
0
const char *cheat_parameter::text()
{
	// are we a value cheat?
	if (!has_itemlist())
	{
		m_curtext = string_format("%d (0x%X)", uint32_t(m_value), uint32_t(m_value));
	}
	else
	{
		// if not, we're an item cheat
		m_curtext = string_format("??? (%d)", uint32_t(m_value));
		for (auto &curitem : m_itemlist)
			if (curitem->value() == m_value)
			{
				m_curtext.assign(curitem->text());
				break;
			}
	}
	return m_curtext.c_str();
}