summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Matthew Daniels <108370479+gm-matthew@users.noreply.github.com>2025-10-30 07:34:13 +0000
committer GitHub <noreply@github.com>2025-10-30 08:34:13 +0100
commita10de08d06c1b763ec710a016bfef0681fe480ff (patch)
treeb7125dfbee11a7fbad6925f262e2927d614d4292
parentd4be3bb639ec9095c8307c5c783a2489b254719e (diff)
sega/model2: new trilinear implementation, add support for microtextures (#14433)
* sega/model2: new trilinear implementation, add support for microtextures New implementation runs about 40% faster * sega/model2.cpp: forgot to remove a redundant line * sega/model2: more redundant lines removed
-rw-r--r--src/devices/video/poly.h5
-rw-r--r--src/mame/sega/model2.cpp14
-rw-r--r--src/mame/sega/model2.h29
-rw-r--r--src/mame/sega/model2_v.cpp76
-rw-r--r--src/mame/sega/model2rd.ipp257
5 files changed, 226 insertions, 155 deletions
diff --git a/src/devices/video/poly.h b/src/devices/video/poly.h
index 8fa63428321..9f1243e2a7b 100644
--- a/src/devices/video/poly.h
+++ b/src/devices/video/poly.h
@@ -280,7 +280,6 @@ public:
{
BaseType start; // parameter value at start
BaseType dpdx; // dp/dx relative to start
- BaseType dpdy; // dp/dy relative to start
};
int16_t startx, stopx; // starting (inclusive)/ending (exclusive) endpoints
std::array<param_t, MaxParams> param; // array of parameter start/delays
@@ -795,7 +794,6 @@ uint32_t poly_manager<BaseType, ObjectType, MaxParams, Flags>::render_tile(recta
{
extent.param[paramnum].start = v1->p[paramnum] + fullstartx * param_dpdx[paramnum] + fully * param_dpdy[paramnum];
extent.param[paramnum].dpdx = param_dpdx[paramnum];
- extent.param[paramnum].dpdy = param_dpdy[paramnum];
}
}
}
@@ -960,7 +958,6 @@ uint32_t poly_manager<BaseType, ObjectType, MaxParams, Flags>::render_triangle(c
{
extent.param[paramnum].start = param_start[paramnum] + fullstartx * param_dpdx[paramnum] + fully * param_dpdy[paramnum];
extent.param[paramnum].dpdx = param_dpdx[paramnum];
- extent.param[paramnum].dpdy = param_dpdy[paramnum];
}
}
}
@@ -1077,7 +1074,6 @@ uint32_t poly_manager<BaseType, ObjectType, MaxParams, Flags>::render_extents(re
{
extent.param[paramnum].start = srcextent.param[paramnum].start;
extent.param[paramnum].dpdx = srcextent.param[paramnum].dpdx;
- extent.param[paramnum].dpdy = srcextent.param[paramnum].dpdy;
}
extent.userdata = srcextent.userdata;
@@ -1260,7 +1256,6 @@ uint32_t poly_manager<BaseType, ObjectType, MaxParams, Flags>::render_polygon(re
extent.param[paramnum].start = lparam;// - (BaseType(istartx) + 0.5f) * dpdx;
extent.param[paramnum].dpdx = dpdx;
- extent.param[paramnum].dpdy = ledge->dpdy[paramnum];
}
}
diff --git a/src/mame/sega/model2.cpp b/src/mame/sega/model2.cpp
index 3e9d0f5dd54..e77511ae146 100644
--- a/src/mame/sega/model2.cpp
+++ b/src/mame/sega/model2.cpp
@@ -10,7 +10,6 @@
MAME driver by R. Belmont, Olivier Galibert, ElSemi, Angelo Salese and Matthew Daniels.
TODO:
- - Mip Mapping still needs to be properly sorted in the renderer;
- outputs and artwork (for gearbox indicators);
- clean-ups;
@@ -1027,14 +1026,14 @@ void model2_tgp_state::tex1_w(offs_t offset, u32 data)
}
}
-u16 model2_state::lumaram_r(offs_t offset)
+u8 model2_state::lumaram_r(offs_t offset)
{
return m_lumaram[offset];
}
-void model2_state::lumaram_w(offs_t offset, u16 data, u16 mem_mask)
+void model2_state::lumaram_w(offs_t offset, u8 data)
{
- COMBINE_DATA(&m_lumaram[offset]);
+ m_lumaram[offset] = data;
}
/* Top Skater reads here and discards the result */
@@ -1106,8 +1105,6 @@ void model2_state::model2_base_mem(address_map &map)
// format is xGGGGGRRRRRBBBBB (512x400)
pre { line-height: 125%; } td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
// license:BSD-3-Clause
// copyright-holders:Couriersud

#include "poptions.h"
#include "pexception.h"
#include "pstrutil.h"
#include "ptypes.h"

namespace plib {

	option_base::option_base(options &parent, const pstring &help)
	: m_help(help)
	{
		parent.register_option(this);
	}

	option::option(options &parent, const pstring &ashort, const pstring &along, const pstring &help, bool has_argument)
	: option_base(parent, help), m_short(ashort), m_long(along),
	  m_has_argument(has_argument), m_specified(false)
	{
	}

	int option_str::parse(const pstring &argument)
	{
		m_val = argument;
		return 0;
	}

	int option_bool::parse(const pstring &argument)
	{
		unused_var(argument);
		m_val = true;
		return 0;
	}

	int option_vec::parse(const pstring &argument)
	{
		bool err = false;
		m_val.push_back(argument);
		return (err ? 1 : 0);
	}

	options::options()
	: m_other_args(nullptr)
	{
	}

	options::options(option **o)
	: m_other_args(nullptr)
	{
		int i=0;
		while (o[i] != nullptr)
		{
			register_option(o[i]);
			i++;
		}
	}

	void options::register_option(option_base *opt)
	{
		m_opts.push_back(opt);
	}

	void options::check_consistency()
	{
		for (auto &opt : m_opts)
		{
			auto *o = dynamic_cast<option *>(opt);
			if (o != nullptr)
			{
				if (o->short_opt().empty() && o->long_opt().empty())
				{
					auto *ov = dynamic_cast<option_args *>(o);
					if (ov != nullptr)
					{
						if (m_other_args != nullptr)
						{
							throw pexception("other args can only be specified once!");
						}

						m_other_args = ov;
					}
					else
						throw pexception("found option with neither short or long tag!" );
				}
			}
		}
	}

	std::size_t options::parse(const std::vector<putf8string> &argv)
	{
		check_consistency();
		m_app = argv[0];
		bool seen_other_args = false;

		for (std::size_t i=1; i < argv.size(); )
		{
			pstring arg(argv[i]);
			option *opt = nullptr;
			pstring opt_arg;
			bool has_equal_arg = false;

			if (!seen_other_args && plib::startsWith(arg, "--"))
			{
				auto v = psplit(arg.substr(2),'=');
				if (!v.empty() && !v[0].empty())
				{
					opt = getopt_long(v[0]);
					has_equal_arg = (v.size() > 1);
					if (has_equal_arg)
					{
						for (std::size_t j = 1; j < v.size() - 1; j++)
							opt_arg += (v[j] + "=");
						opt_arg += v[v.size()-1];
					}
				}
				else
				{
					opt = m_other_args;
					seen_other_args = true;
				}
			}
			else if (!seen_other_args && plib::startsWith(arg, "-"))
			{
				std::size_t p = 1;
				opt = getopt_short(arg.substr(p, 1));
				++p;
				if (p < arg.length())
				{
					has_equal_arg = true;
					opt_arg = arg.substr(p);
				}
			}
			else
			{
				seen_other_args = true;
				if (m_other_args == nullptr)
					return i;
				opt = m_other_args;
				i--; // we haven't had an option specifier;
			}
			if (opt == nullptr)
				return i;
			if (opt->has_argument())
			{
				if (has_equal_arg)
				{
					if (opt->do_parse(opt_arg) != 0)
						return i;
				}
				else
				{
					i++;
					if (i >= argv.size())
						return i - 1;
					if (opt->do_parse(pstring(argv[i])) != 0)
						return i - 1;
				}
			}
			else
			{
				if (has_equal_arg)
					return i;
				opt->do_parse("");
			}
			i++;
		}
		return argv.size();
	}

	pstring options::split_paragraphs(const pstring &text, unsigned width, unsigned indent,
			unsigned firstline_indent, const pstring &line_end)
	{
		auto paragraphs = psplit(text,'\n');
		pstring ret("");

		for (auto &p : paragraphs)
		{
			pstring line = plib::rpad(pstring(""), pstring(" "), firstline_indent);
			for (auto &s : psplit(p, ' '))
			{
				if (line.length() + s.length() > width)
				{
					ret += line + line_end;
					line = plib::rpad(pstring(""), pstring(" "), indent);
				}
				line += s + " ";
			}
			ret += line;
			if (p != paragraphs.back())
				ret += line_end;
		}
		return ret;
	}

	pstring options::help(const pstring &description, const pstring &usage,
			unsigned width, unsigned indent) const
	{
		pstring ret;

		ret = split_paragraphs(description, width, 0, 0) + "\n\n";
		ret += "Usage:\t" + usage + "\n\nOptions:\n\n";

		for (const auto & optbase : m_opts )
		{
			// Skip anonymous inputs which are collected in option_args
			if (dynamic_cast<option_args *>(optbase) != nullptr)
				continue;

			if (auto * const opt = dynamic_cast<option *>(optbase))
			{
				pstring line = "";
				if (!opt->short_opt().empty())
					line += "  -" + opt->short_opt();
				if (!opt->long_opt().empty())
				{
					if (!line.empty())
						line += ", ";
					else
						line = "      ";
					line += "--" + opt->long_opt();
					if (opt->has_argument())
					{
						line += "=";
						auto *ol = dynamic_cast<option_str_limit_base *>(opt);
						if (ol != nullptr)
						{
							for (const auto &v : ol->limit())
							{
								line += v + "|";
							}
							line = plib::left(line, line.length() - 1);
						}
						else
							line += "Value";
					}
				}
				line = plib::rpad(line, pstring(" "), indent - 2) + "  ";
				if (line.length() > indent)
				{
					//ret += "TestGroup abc\n  def gef\nxyz\n\n" ;
					ret += line + "\n";
					ret += split_paragraphs(opt->help(), width, indent, indent) + "\n";
				}
				else
					ret += split_paragraphs(line + opt->help(), width, indent, 0) + "\n";
			}
			else if (auto *grp = dynamic_cast<option_group *>(optbase))
			{
				ret += "\n" + grp->group() + ":\n";
				if (!grp->help().empty())
					ret += split_paragraphs(grp->help(), width, 4, 4) + "\n\n";
			}
		}
		// FIXME: other help ...
		pstring ex("");
		for (const auto & optbase : m_opts )
		{
			if (auto *example = dynamic_cast<option_example *>(optbase))
			{
				// help2man doesn't like \\ line continuation in output
				ex += split_paragraphs(example->example(), width, 8, 0, "\n") + "\n\n";
				ex += split_paragraphs(example->help(), width, 4, 4) + "\n\n";
			}
		}
		if (!ex.empty())
		{
			ret += "\n\nExamples:\n\n" + ex;
		}
		return ret;
	}

	option *options::getopt_short(const pstring &arg) const
	{
		for (const auto & optbase : m_opts)
		{
			auto *opt = dynamic_cast<option *>(optbase);
			if (opt != nullptr && !arg.empty() && opt->short_opt() == arg)
				return opt;
		}
		return nullptr;
	}
	option *options::getopt_long(const pstring &arg) const
	{
		for (const auto & optbase : m_opts)
		{
			auto *opt = dynamic_cast<option *>(optbase);
			if (opt != nullptr && !arg.empty() && opt->long_opt() == arg)
				return opt;
		}
		return nullptr;
	}

} // namespace plib