Fixed Vector Intensity and Flicker

- fixed vector intensity in vector.fx
- fixed vector flicker in vector.c
- change range of vector flicker option from 0 - 100 to 0.00 - 1.00
This commit is contained in:
ImJezze 2015-10-25 11:02:52 +01:00
parent a7b8acbe3e
commit 0ad0e5548e
4 changed files with 53 additions and 32 deletions

View File

@ -42,15 +42,19 @@ uniform float3 LengthParams;
VS_OUTPUT vs_main(VS_INPUT Input) VS_OUTPUT vs_main(VS_INPUT Input)
{ {
VS_OUTPUT Output = (VS_OUTPUT)0; VS_OUTPUT Output = (VS_OUTPUT)0;
Output.Position = float4(Input.Position.xyz, 1.0f); Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims; Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y; Output.Position.y = 1.0f - Output.Position.y; // flip y
Output.Position.xy -= 0.5f; Output.Position.xy -= 0.5f; // center
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Position.xy *= 2.0f; // zoom
Output.Color = Input.Color;
Output.TexCoord = Input.Position.xy / ScreenDims; Output.TexCoord = Input.Position.xy / ScreenDims;
Output.Color = Input.Color;
Output.LineInfo = Input.LineInfo; Output.LineInfo = Input.LineInfo;
return Output; return Output;
} }
@ -64,14 +68,14 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// LengthParams.z: Size at which fade is maximum // LengthParams.z: Size at which fade is maximum
float4 ps_main(PS_INPUT Input) : COLOR float4 ps_main(PS_INPUT Input) : COLOR
{ {
float timeModulate = lerp(1.0f, TimeParams.x, TimeParams.y) * 1.0; float timeModulate = lerp(1.0f, TimeParams.x, TimeParams.y);
float lengthModulate = 1.0f - clamp(Input.LineInfo.x / LengthParams.z, 0.0f, 1.0f); float lengthModulate = 1.0f - clamp(Input.LineInfo.x / LengthParams.z, 0.0f, 1.0f);
float minLength = 2.0f - clamp(Input.LineInfo.x - 1.0f, 0.0f, 2.0f); float minLength = 2.0f - clamp(Input.LineInfo.x - 1.0f, 0.0f, 2.0f);
lengthModulate = lerp(lengthModulate, 4.0f, minLength * 0.5f); lengthModulate = lerp(lengthModulate, 2.0f, minLength * 0.5f);
lengthModulate = lerp(1.0f, timeModulate * lengthModulate, LengthParams.y) * 1.0; lengthModulate = lerp(1.0f, timeModulate * lengthModulate, LengthParams.y);
float4 outColor = Input.Color * float4(lengthModulate, lengthModulate, lengthModulate, 1.0f) * 2.0; float4 outColor = Input.Color * float4(lengthModulate, lengthModulate, lengthModulate, 1.0f);
return outColor; return outColor;
} }

View File

@ -2340,10 +2340,10 @@ static INT32 slider_flicker(running_machine &machine, void *arg, std::string *st
{ {
vector_device *vector = NULL; vector_device *vector = NULL;
if (newval != SLIDER_NOCHANGE) if (newval != SLIDER_NOCHANGE)
vector->set_flicker((float)newval * 0.1f); vector->set_flicker((float)newval * 0.001f);
if (str != NULL) if (str != NULL)
strprintf(*str,"%1.2f", (double) vector->get_flicker()); strprintf(*str,"%1.2f", (double) vector->get_flicker());
return floor(vector->get_flicker() * 10.0f + 0.5f); return floor(vector->get_flicker() * 1000.0f + 0.5f);
} }

View File

@ -140,9 +140,8 @@ vector_device::vector_device(const machine_config &mconfig, const char *tag, dev
{ {
} }
float vector_device::m_flicker_correction = 0.0f; float vector_device::m_flicker = 0.0f;
float vector_device::m_beam_width = 0.0f; float vector_device::m_beam_width = 0.0f;
int vector_device::m_flicker;
int vector_device::m_vector_index; int vector_device::m_vector_index;
void vector_device::device_start() void vector_device::device_start()
@ -160,13 +159,12 @@ void vector_device::device_start()
void vector_device::set_flicker(float _flicker) void vector_device::set_flicker(float _flicker)
{ {
m_flicker_correction = _flicker; m_flicker = _flicker;
m_flicker = (int)(m_flicker_correction * 2.55f);
} }
float vector_device::get_flicker() float vector_device::get_flicker()
{ {
return m_flicker_correction; return m_flicker;
} }
void vector_device::set_beam(float _beam) void vector_device::set_beam(float _beam)
@ -184,21 +182,30 @@ float vector_device::get_beam()
* Adds a line end point to the vertices list. The vector processor emulation * Adds a line end point to the vertices list. The vector processor emulation
* needs to call this. * needs to call this.
*/ */
void vector_device::add_point (int x, int y, rgb_t color, int intensity) void vector_device::add_point(int x, int y, rgb_t color, int intensity)
{ {
point *newpoint; point *newpoint;
if (intensity > 0xff) if (intensity > 255)
intensity = 0xff; {
intensity = 255;
}
if (m_flicker && (intensity > 0)) if (m_flicker && (intensity > 0))
{ {
intensity += (intensity * (0x80-(machine().rand()&0xff)) * m_flicker)>>16; float random = (float)(machine().rand() & 255) / 255.0f; // random value between 0.0 and 1.0
intensity -= (int)(intensity * random * m_flicker);
if (intensity < 0) if (intensity < 0)
{
intensity = 0; intensity = 0;
if (intensity > 0xff) }
intensity = 0xff; if (intensity > 255)
{
intensity = 255;
}
} }
newpoint = &m_vector_list[m_vector_index]; newpoint = &m_vector_list[m_vector_index];
newpoint->x = x; newpoint->x = x;
newpoint->y = y; newpoint->y = y;
@ -214,10 +221,11 @@ void vector_device::add_point (int x, int y, rgb_t color, int intensity)
} }
} }
/* /*
* Add new clipping info to the list * Add new clipping info to the list
*/ */
void vector_device::add_clip (int x1, int yy1, int x2, int y2) void vector_device::add_clip(int x1, int yy1, int x2, int y2)
{ {
point *newpoint; point *newpoint;
@ -241,7 +249,7 @@ void vector_device::add_clip (int x1, int yy1, int x2, int y2)
* The vector CPU creates a new display list. We save the old display list, * The vector CPU creates a new display list. We save the old display list,
* but only once per refresh. * but only once per refresh.
*/ */
void vector_device::clear_list (void) void vector_device::clear_list(void)
{ {
m_vector_index = 0; m_vector_index = 0;
} }
@ -286,22 +294,32 @@ UINT32 vector_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
} }
else else
{ {
// todo: implement beam_width_overdrive based on intensity
float beam_width = m_beam_width * (1.0f / (float)VECTOR_WIDTH_DENOM);
coords.x0 = ((float)lastx - xoffs) * xscale; coords.x0 = ((float)lastx - xoffs) * xscale;
coords.y0 = ((float)lasty - yoffs) * yscale; coords.y0 = ((float)lasty - yoffs) * yscale;
coords.x1 = ((float)curpoint->x - xoffs) * xscale; coords.x1 = ((float)curpoint->x - xoffs) * xscale;
coords.y1 = ((float)curpoint->y - yoffs) * yscale; coords.y1 = ((float)curpoint->y - yoffs) * yscale;
if (curpoint->intensity != 0) // todo: extend line length by half beam_width on both sides
if (!render_clip_line(&coords, &clip))
screen.container().add_line(coords.x0, coords.y0, coords.x1, coords.y1, if (curpoint->intensity != 0 && !render_clip_line(&coords, &clip))
m_beam_width * (1.0f / (float)VECTOR_WIDTH_DENOM), {
(curpoint->intensity << 24) | (curpoint->col & 0xffffff), screen.container().add_line(
flags); coords.x0, coords.y0, coords.x1, coords.y1,
beam_width,
(curpoint->intensity << 24) | (curpoint->col & 0xffffff),
flags);
}
lastx = curpoint->x; lastx = curpoint->x;
lasty = curpoint->y; lasty = curpoint->y;
} }
curpoint++; curpoint++;
} }
return 0; return 0;
} }

View File

@ -56,8 +56,7 @@ public:
virtual void device_start(); virtual void device_start();
private: private:
static int m_flicker; /* beam flicker value */ static float m_flicker;
static float m_flicker_correction;
static float m_beam_width; static float m_beam_width;
point *m_vector_list; point *m_vector_list;
static int m_vector_index; static int m_vector_index;