mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
Make core vector-related slider handling slightly less egregious, nw
This commit is contained in:
parent
fbc8dbf193
commit
0233dd4dbf
@ -2402,12 +2402,11 @@ static INT32 slider_overyoffset(running_machine &machine, void *arg, int id, std
|
||||
|
||||
static INT32 slider_flicker(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
|
||||
{
|
||||
vector_device *vector = nullptr;
|
||||
if (newval != SLIDER_NOCHANGE)
|
||||
vector->set_flicker((float)newval * 0.001f);
|
||||
vector_options::s_flicker = (float)newval * 0.001f;
|
||||
if (str)
|
||||
*str = string_format(_("%1$1.2f"), vector->get_flicker());
|
||||
return floor(vector->get_flicker() * 1000.0f + 0.5f);
|
||||
*str = string_format(_("%1$1.2f"), vector_options::s_flicker);
|
||||
return floor(vector_options::s_flicker * 1000.0f + 0.5f);
|
||||
}
|
||||
|
||||
|
||||
@ -2418,12 +2417,11 @@ static INT32 slider_flicker(running_machine &machine, void *arg, int id, std::st
|
||||
|
||||
static INT32 slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
|
||||
{
|
||||
vector_device *vector = nullptr;
|
||||
if (newval != SLIDER_NOCHANGE)
|
||||
vector->set_beam_width_min(MIN((float)newval * 0.01f, vector->get_beam_width_max()));
|
||||
vector_options::s_beam_width_min = MIN((float)newval * 0.01f, vector_options::s_beam_width_max);
|
||||
if (str != nullptr)
|
||||
*str = string_format(_("%1$1.2f"), vector->get_beam_width_min());
|
||||
return floor(vector->get_beam_width_min() * 100.0f + 0.5f);
|
||||
*str = string_format(_("%1$1.2f"), vector_options::s_beam_width_min);
|
||||
return floor(vector_options::s_beam_width_min * 100.0f + 0.5f);
|
||||
}
|
||||
|
||||
|
||||
@ -2434,12 +2432,11 @@ static INT32 slider_beam_width_min(running_machine &machine, void *arg, int id,
|
||||
|
||||
static INT32 slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
|
||||
{
|
||||
vector_device *vector = nullptr;
|
||||
if (newval != SLIDER_NOCHANGE)
|
||||
vector->set_beam_width_max(MAX((float)newval * 0.01f, vector->get_beam_width_min()));
|
||||
vector_options::s_beam_width_max = MAX((float)newval * 0.01f, vector_options::s_beam_width_min);
|
||||
if (str != nullptr)
|
||||
*str = string_format(_("%1$1.2f"), vector->get_beam_width_max());
|
||||
return floor(vector->get_beam_width_max() * 100.0f + 0.5f);
|
||||
*str = string_format(_("%1$1.2f"), vector_options::s_beam_width_max);
|
||||
return floor(vector_options::s_beam_width_max * 100.0f + 0.5f);
|
||||
}
|
||||
|
||||
|
||||
@ -2450,12 +2447,11 @@ static INT32 slider_beam_width_max(running_machine &machine, void *arg, int id,
|
||||
|
||||
static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
|
||||
{
|
||||
vector_device *vector = nullptr;
|
||||
if (newval != SLIDER_NOCHANGE)
|
||||
vector->set_beam_intensity_weight((float)newval * 0.001f);
|
||||
vector_options::s_beam_intensity_weight = (float)newval * 0.001f;
|
||||
if (str != nullptr)
|
||||
*str = string_format(_("%1$1.2f"), vector->get_beam_intensity_weight());
|
||||
return floor(vector->get_beam_intensity_weight() * 1000.0f + 0.5f);
|
||||
*str = string_format(_("%1$1.2f"), vector_options::s_beam_intensity_weight);
|
||||
return floor(vector_options::s_beam_intensity_weight * 1000.0f + 0.5f);
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,6 +54,19 @@
|
||||
"Andrew Caldwell (anti-aliasing)\n" \
|
||||
"- *** -\n"
|
||||
|
||||
float vector_options::s_flicker = 0.0f;
|
||||
float vector_options::s_beam_width_min = 0.0f;
|
||||
float vector_options::s_beam_width_max = 0.0f;
|
||||
float vector_options::s_beam_intensity_weight = 0.0f;
|
||||
|
||||
void vector_options::init(emu_options& options)
|
||||
{
|
||||
s_beam_width_min = options.beam_width_min();
|
||||
s_beam_width_max = options.beam_width_max();
|
||||
s_beam_intensity_weight = options.beam_intensity_weight();
|
||||
s_flicker = options.flicker();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
#define TEXTURE_LENGTH_BUCKETS 32
|
||||
@ -146,19 +159,9 @@ vector_device::vector_device(const machine_config &mconfig, const char *tag, dev
|
||||
{
|
||||
}
|
||||
|
||||
float vector_device::m_flicker = 0.0f;
|
||||
float vector_device::m_beam_width_min = 0.0f;
|
||||
float vector_device::m_beam_width_max = 0.0f;
|
||||
float vector_device::m_beam_intensity_weight = 0.0f;
|
||||
int vector_device::m_vector_index;
|
||||
|
||||
void vector_device::device_start()
|
||||
{
|
||||
/* Grab the settings for this session */
|
||||
m_beam_width_min = machine().options().beam_width_min();
|
||||
m_beam_width_max = machine().options().beam_width_max();
|
||||
m_beam_intensity_weight = machine().options().beam_intensity_weight();
|
||||
m_flicker = machine().options().flicker();
|
||||
vector_options::init(machine().options());
|
||||
|
||||
m_vector_index = 0;
|
||||
|
||||
@ -166,47 +169,6 @@ void vector_device::device_start()
|
||||
m_vector_list = make_unique_clear<point[]>(MAX_POINTS);
|
||||
}
|
||||
|
||||
void vector_device::set_flicker(float newval)
|
||||
{
|
||||
m_flicker = newval;
|
||||
}
|
||||
|
||||
float vector_device::get_flicker()
|
||||
{
|
||||
return m_flicker;
|
||||
}
|
||||
|
||||
void vector_device::set_beam_width_min(float newval)
|
||||
{
|
||||
m_beam_width_min = newval;
|
||||
}
|
||||
|
||||
float vector_device::get_beam_width_min()
|
||||
{
|
||||
return m_beam_width_min;
|
||||
}
|
||||
|
||||
void vector_device::set_beam_width_max(float newval)
|
||||
{
|
||||
m_beam_width_max = newval;
|
||||
}
|
||||
|
||||
float vector_device::get_beam_width_max()
|
||||
{
|
||||
return m_beam_width_max;
|
||||
}
|
||||
|
||||
void vector_device::set_beam_intensity_weight(float newval)
|
||||
{
|
||||
m_beam_intensity_weight = newval;
|
||||
}
|
||||
|
||||
float vector_device::get_beam_intensity_weight()
|
||||
{
|
||||
return m_beam_intensity_weight;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* www.dinodini.wordpress.com/2010/04/05/normalized-tunable-sigmoid-functions/
|
||||
*/
|
||||
@ -230,11 +192,11 @@ void vector_device::add_point(int x, int y, rgb_t color, int intensity)
|
||||
m_min_intensity = intensity > 0 ? MIN(m_min_intensity, intensity) : m_min_intensity;
|
||||
m_max_intensity = intensity > 0 ? MAX(m_max_intensity, intensity) : m_max_intensity;
|
||||
|
||||
if (m_flicker && (intensity > 0))
|
||||
if (vector_options::s_flicker && (intensity > 0))
|
||||
{
|
||||
float random = (float)(machine().rand() & 255) / 255.0f; // random value between 0.0 and 1.0
|
||||
|
||||
intensity -= (int)(intensity * random * m_flicker);
|
||||
intensity -= (int)(intensity * random * vector_options::s_flicker);
|
||||
|
||||
intensity = MAX(0, MIN(255, intensity));
|
||||
}
|
||||
@ -290,7 +252,7 @@ void vector_device::clear_list(void)
|
||||
|
||||
UINT32 vector_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
UINT32 flags = PRIMFLAG_ANTIALIAS(screen.machine().options().antialias() ? 1 : 0) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD) | PRIMFLAG_VECTOR(1);
|
||||
UINT32 flags = PRIMFLAG_ANTIALIAS(machine().options().antialias() ? 1 : 0) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD) | PRIMFLAG_VECTOR(1);
|
||||
const rectangle &visarea = screen.visible_area();
|
||||
float xscale = 1.0f / (65536 * visarea.width());
|
||||
float yscale = 1.0f / (65536 * visarea.height());
|
||||
@ -333,12 +295,12 @@ UINT32 vector_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
|
||||
else
|
||||
{
|
||||
float intensity = (float)curpoint->intensity / 255.0f;
|
||||
float intensity_weight = normalized_sigmoid(intensity, m_beam_intensity_weight);
|
||||
float intensity_weight = normalized_sigmoid(intensity, vector_options::s_beam_intensity_weight);
|
||||
|
||||
// check for static intensity
|
||||
float beam_width = m_min_intensity == m_max_intensity
|
||||
? m_beam_width_min
|
||||
: m_beam_width_min + intensity_weight * (m_beam_width_max - m_beam_width_min);
|
||||
? vector_options::s_beam_width_min
|
||||
: vector_options::s_beam_width_min + intensity_weight * (vector_options::s_beam_width_max - vector_options::s_beam_width_min);
|
||||
|
||||
// normalize width
|
||||
beam_width *= 1.0f / (float)VECTOR_WIDTH_DENOM;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define VECTOR_COLOR444(c) \
|
||||
rgb_t(pal4bit((c) >> 8), pal4bit((c) >> 4), pal4bit((c) >> 0))
|
||||
|
||||
class vector_device;
|
||||
|
||||
/* The vertices are buffered here */
|
||||
struct point
|
||||
@ -32,6 +33,20 @@ struct point
|
||||
int status; /* for dirty and clipping handling */
|
||||
};
|
||||
|
||||
class vector_options
|
||||
{
|
||||
public:
|
||||
friend class vector_device;
|
||||
|
||||
static float s_flicker;
|
||||
static float s_beam_width_min;
|
||||
static float s_beam_width_max;
|
||||
static float s_beam_intensity_weight;
|
||||
|
||||
protected:
|
||||
static void init(emu_options& options);
|
||||
};
|
||||
|
||||
class vector_device : public device_t, public device_video_interface
|
||||
{
|
||||
public:
|
||||
@ -61,19 +76,14 @@ public:
|
||||
virtual void device_start() override;
|
||||
|
||||
private:
|
||||
static float m_flicker;
|
||||
static float m_beam_width_min;
|
||||
static float m_beam_width_max;
|
||||
static float m_beam_intensity_weight;
|
||||
std::unique_ptr<point[]> m_vector_list;
|
||||
static int m_vector_index;
|
||||
int m_vector_index;
|
||||
int m_min_intensity;
|
||||
int m_max_intensity;
|
||||
|
||||
float normalized_sigmoid(float n, float k);
|
||||
};
|
||||
|
||||
|
||||
// device type definition
|
||||
extern const device_type VECTOR;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user