Previous 199869 Revisions Next

r41379 Sunday 25th October, 2015 at 19:54:00 UTC by Jezze
Experimental Dynamic Beam Width

- replace beam width by beam min. and beam max. width, this makes it
possible to create a linear dynamic beam width by the amount of
intensity of the beam
- added beam intensity weight, this adds an exponential factor to the
dynamic beam width (values greater than 0 will push larger intensities
more than smaller intensities)
- fixed displayed ratio of vector points (zero-length lines)
[src/emu]emuopts.c emuopts.h
[src/emu/ui]ui.c
[src/emu/video]vector.c vector.h
[src/osd/sdl]video.c

trunk/src/emu/emuopts.c
r249890r249891
112112   // vector options
113113   { NULL,                                              NULL,        OPTION_HEADER,     "CORE VECTOR OPTIONS" },
114114   { OPTION_ANTIALIAS ";aa",                            "1",         OPTION_BOOLEAN,    "use antialiasing when drawing vectors" },
115   { OPTION_BEAM,                                       "1.0",       OPTION_FLOAT,      "set vector beam width" },
115   { OPTION_BEAM_MIN,                                   "1.0",       OPTION_FLOAT,      "set vector beam width minimum" },
116   { OPTION_BEAM_MAX,                                   "1.0",       OPTION_FLOAT,      "set vector beam width maximum" },
117   { OPTION_BEAM_INTENSITY_WEIGHT,                      "0",         OPTION_FLOAT,      "set vector beam intensity weight " },
116118   { OPTION_FLICKER,                                    "0",         OPTION_FLOAT,      "set vector flicker effect" },
117119
118120   // sound options
trunk/src/emu/emuopts.h
r249890r249891
119119
120120// core vector options
121121#define OPTION_ANTIALIAS            "antialias"
122#define OPTION_BEAM                 "beam"
122#define OPTION_BEAM_MIN             "beam_min"
123#define OPTION_BEAM_MAX             "beam_max"
124#define OPTION_BEAM_INTENSITY_WEIGHT   "beam_intensity_weight"
123125#define OPTION_FLICKER              "flicker"
124126
125127// core sound options
r249890r249891
296298
297299   // core vector options
298300   bool antialias() const { return bool_value(OPTION_ANTIALIAS); }
299   float beam() const { return float_value(OPTION_BEAM); }
301   float beam_min() const { return float_value(OPTION_BEAM_MIN); }
302   float beam_max() const { return float_value(OPTION_BEAM_MAX); }
303   float beam_intensity_weight() const { return float_value(OPTION_BEAM_INTENSITY_WEIGHT); }
300304   float flicker() const { return float_value(OPTION_FLICKER); }
301305
302306   // core sound options
trunk/src/emu/ui/ui.c
r249890r249891
124124static INT32 slider_overxoffset(running_machine &machine, void *arg, std::string *str, INT32 newval);
125125static INT32 slider_overyoffset(running_machine &machine, void *arg, std::string *str, INT32 newval);
126126static INT32 slider_flicker(running_machine &machine, void *arg, std::string *str, INT32 newval);
127static INT32 slider_beam(running_machine &machine, void *arg, std::string *str, INT32 newval);
127static INT32 slider_beam_min(running_machine &machine, void *arg, std::string *str, INT32 newval);
128static INT32 slider_beam_max(running_machine &machine, void *arg, std::string *str, INT32 newval);
129static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, std::string *str, INT32 newval);
128130static char *slider_get_screen_desc(screen_device &screen);
129131#ifdef MAME_DEBUG
130132static INT32 slider_crossscale(running_machine &machine, void *arg, std::string *str, INT32 newval);
r249890r249891
19641966   for (screen_device *screen = scriter.first(); screen != NULL; screen = scriter.next())
19651967      if (screen->screen_type() == SCREEN_TYPE_VECTOR)
19661968      {
1967         // add flicker control
1969         // add vector control
19681970         *tailptr = slider_alloc(machine, "Vector Flicker", 0, 0, 1000, 10, slider_flicker, NULL);
19691971         tailptr = &(*tailptr)->next;
1970         *tailptr = slider_alloc(machine, "Beam Width", 10, 100, 1000, 10, slider_beam, NULL);
1972         *tailptr = slider_alloc(machine, "Beam Width Minimum", 10, 100, 1000, 10, slider_beam_min, NULL);
19711973         tailptr = &(*tailptr)->next;
1974         *tailptr = slider_alloc(machine, "Beam Width Maximum", 10, 100, 1000, 10, slider_beam_max, NULL);
1975         tailptr = &(*tailptr)->next;
1976         *tailptr = slider_alloc(machine, "Beam Intensity Weight", -1000, 0, 1000, 10, slider_beam_intensity_weight, NULL);
1977         tailptr = &(*tailptr)->next;
19721978         break;
19731979      }
19741980
r249890r249891
23482354
23492355
23502356//-------------------------------------------------
2351//  slider_beam - vector beam width slider
2357//  slider_beam_min - minimum vector beam width slider
23522358//  callback
23532359//-------------------------------------------------
23542360
2355static INT32 slider_beam(running_machine &machine, void *arg, std::string *str, INT32 newval)
2361static INT32 slider_beam_min(running_machine &machine, void *arg, std::string *str, INT32 newval)
23562362{
23572363   vector_device *vector = NULL;
23582364   if (newval != SLIDER_NOCHANGE)
2359      vector->set_beam((float)newval * 0.01f);
2365      vector->set_beam_min(MIN((float)newval * 0.001f, vector->get_beam_max()));
23602366   if (str != NULL)
2361      strprintf(*str,"%1.2f", (double) vector->get_beam());
2362   return floor(vector->get_beam() * 100.0f + 0.5f);
2367      strprintf(*str,"%1.2f", (double) vector->get_beam_min());
2368   return floor(vector->get_beam_min() * 1000.0f + 0.5f);
23632369}
23642370
23652371
23662372//-------------------------------------------------
2373//  slider_beam_max - maximum vector beam width slider
2374//  callback
2375//-------------------------------------------------
2376
2377static INT32 slider_beam_max(running_machine &machine, void *arg, std::string *str, INT32 newval)
2378{
2379   vector_device *vector = NULL;
2380   if (newval != SLIDER_NOCHANGE)
2381      vector->set_beam_max(MAX((float)newval * 0.001f, vector->get_beam_min()));
2382   if (str != NULL)
2383      strprintf(*str,"%1.2f", (double) vector->get_beam_max());
2384   return floor(vector->get_beam_max() * 1000.0f + 0.5f);
2385}
2386
2387
2388//-------------------------------------------------
2389//  slider_beam_intensity_weight - vector beam intensity weight slider
2390//  callback
2391//-------------------------------------------------
2392
2393static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, std::string *str, INT32 newval)
2394{
2395   vector_device *vector = NULL;
2396   if (newval != SLIDER_NOCHANGE)
2397      vector->set_beam_intensity_weight((float)newval * 0.001f);
2398   if (str != NULL)
2399      strprintf(*str,"%1.2f", (double) vector->get_beam_intensity_weight());
2400   return floor(vector->get_beam_intensity_weight() * 1000.0f + 0.5f);
2401}
2402
2403
2404//-------------------------------------------------
23672405//  slider_get_screen_desc - returns the
23682406//  description for a given screen
23692407//-------------------------------------------------
trunk/src/emu/video/vector.c
r249890r249891
3535#include "vector.h"
3636
3737
38#define FLT_EPSILON 1E-5
3839
39#define VECTOR_WIDTH_DENOM          512
40#define VECTOR_WIDTH_DENOM 512
4041
42#define MAX_POINTS 10000
4143
42#define MAX_POINTS  10000
43
4444#define VECTOR_TEAM \
4545   "-* Vector Heads *-\n" \
4646   "Brad Oliver\n" \
r249890r249891
141141}
142142
143143float vector_device::m_flicker = 0.0f;
144float vector_device::m_beam_width = 0.0f;
144float vector_device::m_beam_width_min = 0.0f;
145float vector_device::m_beam_width_max = 0.0f;
146float vector_device::m_beam_intensity_weight = 0.0f;
145147int vector_device::m_vector_index;
146148
147149void vector_device::device_start()
148150{
149   m_beam_width = machine().options().beam();
150
151151   /* Grab the settings for this session */
152   set_flicker(machine().options().flicker());
152   m_beam_width_min = machine().options().beam_min();
153   m_beam_width_max = machine().options().beam_max();
154   m_beam_intensity_weight = machine().options().beam_intensity_weight();
155   m_flicker = machine().options().flicker();
153156
154157   m_vector_index = 0;
155158
r249890r249891
167170   return m_flicker;
168171}
169172
170void vector_device::set_beam(float _beam)
173void vector_device::set_beam_min(float _beam)
171174{
172   m_beam_width = _beam;
175   m_beam_width_min = _beam;
173176}
174177
175float vector_device::get_beam()
178float vector_device::get_beam_min()
176179{
177   return m_beam_width;
180   return m_beam_width_min;
178181}
179182
183void vector_device::set_beam_max(float _beam)
184{
185   m_beam_width_max = _beam;
186}
180187
188float vector_device::get_beam_max()
189{
190   return m_beam_width_max;
191}
192
193void vector_device::set_beam_intensity_weight(float _beam)
194{
195   m_beam_intensity_weight = _beam;
196}
197
198float vector_device::get_beam_intensity_weight()
199{
200   return m_beam_intensity_weight;
201}
202
203
181204/*
205 * www.dinodini.wordpress.com/2010/04/05/normalized-tunable-sigmoid-functions/
206 */
207float vector_device::normalized_sigmoid(float n, float k)
208{
209   // valid for n and k in range of -1.0 and 1.0
210   return (n - n * k) / (k - fabs(n) * 2.0f * k + 1.0f);
211}
212
213
214/*
182215 * Adds a line end point to the vertices list. The vector processor emulation
183216 * needs to call this.
184217 */
r249890r249891
263296   float yscale = 1.0f / (65536 * visarea.height());
264297   float xoffs = (float)visarea.min_x;
265298   float yoffs = (float)visarea.min_y;
299   float xratio = xscale / yscale;
300   float yratio = yscale / xscale;
301   xratio = (xratio < 1.0f) ? xratio : 1.0f;
302   xratio = (yratio < 1.0f) ? yratio : 1.0f;
303
266304   point *curpoint;
267305   render_bounds clip;
268   int lastx = 0, lasty = 0;
269   int i;
306   int lastx = 0;
307   int lasty = 0;
270308
271309   curpoint = m_vector_list;
272310
r249890r249891
276314   clip.x0 = clip.y0 = 0.0f;
277315   clip.x1 = clip.y1 = 1.0f;
278316
279   for (i = 0; i < m_vector_index; i++)
317   for (int i = 0; i < m_vector_index; i++)
280318   {
281319      render_bounds coords;
282320
r249890r249891
294332      }
295333      else
296334      {
297         // todo: implement beam_width_overdrive based on intensity
335         float intensity = (float)curpoint->intensity / 255.0f;
336         float intensity_weight = normalized_sigmoid(intensity, m_beam_intensity_weight);
298337
299         float beam_width = m_beam_width * (1.0f / (float)VECTOR_WIDTH_DENOM);
338         float beam_intensity_width = (m_beam_width_max - m_beam_width_min) * intensity_weight + m_beam_width_min;
339         float beam_width = beam_intensity_width * (1.0f / (float)VECTOR_WIDTH_DENOM);
300340
301341         coords.x0 = ((float)lastx - xoffs) * xscale;
302342         coords.y0 = ((float)lasty - yoffs) * yscale;
303343         coords.x1 = ((float)curpoint->x - xoffs) * xscale;
304344         coords.y1 = ((float)curpoint->y - yoffs) * yscale;
305345
306         // todo: extend line length by half beam_width on both sides
346         // extend zero-length vector line (vector point) by quarter beam_width on both sides
347         if (fabs(coords.x0 - coords.x1) < FLT_EPSILON &&
348            fabs(coords.y0 - coords.y1) < FLT_EPSILON)
349         {
350            coords.x0 += xratio * beam_width * 0.25f;
351            coords.y0 += yratio * beam_width * 0.25f;
352            coords.x1 -= xratio * beam_width * 0.25f;
353            coords.y1 -= yratio * beam_width * 0.25f;
354         }
307355
308356         if (curpoint->intensity != 0 && !render_clip_line(&coords, &clip))
309357         {
trunk/src/emu/video/vector.h
r249890r249891
1616/* The vertices are buffered here */
1717struct point
1818{
19      point():
19   point() :
2020      x(0),
2121      y(0),
2222      col(0),
r249890r249891
3232   int status;         /* for dirty and clipping handling */
3333};
3434
35class vector_device :  public device_t,
36                     public device_video_interface
35class vector_device : public device_t, public device_video_interface
3736{
3837public:
3938   // construction/destruction
r249890r249891
4645   void add_point(int x, int y, rgb_t color, int intensity);
4746   void add_clip(int minx, int miny, int maxx, int maxy);
4847
49   void set_flicker(float m_flicker_correction);
48   void set_flicker(float m_flicker);
5049   float get_flicker();
5150
52   void set_beam(float _beam);
53   float get_beam();
51   void set_beam_min(float _beam);
52   float get_beam_min();
5453
54   void set_beam_max(float _beam);
55   float get_beam_max();
56
57   void set_beam_intensity_weight(float _beam);
58   float get_beam_intensity_weight();
59
5560   // device-level overrides
5661   virtual void device_start();
5762
5863private:
5964   static float m_flicker;
60   static float m_beam_width;
65   static float m_beam_width_min;
66   static float m_beam_width_max;
67   static float m_beam_intensity_weight;
6168   point *m_vector_list;
6269   static int m_vector_index;
70
71   float normalized_sigmoid(float n, float k);
6372};
6473
6574
trunk/src/osd/sdl/video.c
r249890r249891
9696   sdl_monitor_info::init();
9797
9898   // we need the beam width in a float, contrary to what the core does.
99   video_config.beamwidth = options().beam();
99   video_config.beamwidth = options().beam_min();
100100
101101   // initialize the window system so we can make windows
102102   if (!window_init())


Previous 199869 Revisions Next


© 1997-2024 The MAME Team