diff options
author | 2013-11-01 12:17:25 +0000 | |
---|---|---|
committer | 2013-11-01 12:17:25 +0000 | |
commit | f1d1476fb56345d70c347990fbbba2242992cd26 (patch) | |
tree | 53f42692c5244e4f78b6bd1603c7cf164d685ab8 /src/emu | |
parent | 54751a69bd70f13d479e100c949a7f5546042aae (diff) |
Device-ified vector.c. (nw)
Diffstat (limited to 'src/emu')
-rw-r--r-- | src/emu/ui.c | 15 | ||||
-rw-r--r-- | src/emu/video/vector.c | 107 | ||||
-rw-r--r-- | src/emu/video/vector.h | 64 |
3 files changed, 114 insertions, 72 deletions
diff --git a/src/emu/ui.c b/src/emu/ui.c index 201163912c3..926052a92ce 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -2214,14 +2214,14 @@ static INT32 slider_overyoffset(running_machine &machine, void *arg, astring *st static INT32 slider_flicker(running_machine &machine, void *arg, astring *string, INT32 newval) { + vector_device *vector = NULL; if (newval != SLIDER_NOCHANGE) - vector_set_flicker((float)newval * 0.1f); + vector->set_flicker((float)newval * 0.1f); if (string != NULL) - string->printf("%1.2f", vector_get_flicker()); - return floor(vector_get_flicker() * 10.0f + 0.5f); + string->printf("%1.2f", vector->get_flicker()); + return floor(vector->get_flicker() * 10.0f + 0.5f); } - /*------------------------------------------------- slider_beam - vector beam width slider callback @@ -2229,11 +2229,12 @@ static INT32 slider_flicker(running_machine &machine, void *arg, astring *string static INT32 slider_beam(running_machine &machine, void *arg, astring *string, INT32 newval) { + vector_device *vector = NULL; if (newval != SLIDER_NOCHANGE) - vector_set_beam((float)newval * 0.01f); + vector->set_beam((float)newval * 0.01f); if (string != NULL) - string->printf("%1.2f", vector_get_beam()); - return floor(vector_get_beam() * 100.0f + 0.5f); + string->printf("%1.2f", vector->get_beam()); + return floor(vector->get_beam() * 100.0f + 0.5f); } diff --git a/src/emu/video/vector.c b/src/emu/video/vector.c index 5a6652b2523..4417080a48b 100644 --- a/src/emu/video/vector.c +++ b/src/emu/video/vector.c @@ -126,63 +126,58 @@ static render_texture *get_vector_texture(float dx, float dy, float intensity) #define VDIRTY 1 #define VCLIP 2 -/* The vertices are buffered here */ -struct point -{ - int x; int y; - rgb_t col; - int intensity; - int arg1; int arg2; /* start/end in pixel array or clipping info */ - int status; /* for dirty and clipping handling */ -}; +// device type definition +const device_type VECTOR = &device_creator<vector_device>; +vector_device::vector_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) + : device_t(mconfig, type, name, tag, owner, clock, shortname, source), + device_video_interface(mconfig, *this) +{ +} +vector_device::vector_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, VECTOR, "VECTOR", tag, owner, clock, "vector", __FILE__), + device_video_interface(mconfig, *this) +{ +} -static int flicker; /* beam flicker value */ -static float flicker_correction = 0.0f; +float vector_device::m_flicker_correction = 0.0f; +float vector_device::m_beam_width = 0.0f; +int vector_device::m_flicker; +int vector_device::m_vector_index; -static float beam_width; +void vector_device::device_start() +{ + m_beam_width = machine().options().beam(); -static point *vector_list; -static int vector_index; + /* Grab the settings for this session */ + set_flicker(machine().options().flicker()); + m_vector_index = 0; -void vector_set_flicker(float _flicker) -{ - flicker_correction = _flicker; - flicker = (int)(flicker_correction * 2.55); + /* allocate memory for tables */ + m_vector_list = auto_alloc_array_clear(machine(), point, MAX_POINTS); } -float vector_get_flicker(void) +void vector_device::set_flicker(float _flicker) { - return flicker_correction; + m_flicker_correction = _flicker; + m_flicker = (int)(m_flicker_correction * 2.55); } -void vector_set_beam(float _beam) +float vector_device::get_flicker() { - beam_width = _beam; + return m_flicker_correction; } -float vector_get_beam(void) +void vector_device::set_beam(float _beam) { - return beam_width; + m_beam_width = _beam; } -/* - * Initializes vector game video emulation - */ - -VIDEO_START( vector ) +float vector_device::get_beam() { - beam_width = machine.options().beam(); - - /* Grab the settings for this session */ - vector_set_flicker(machine.options().flicker()); - - vector_index = 0; - - /* allocate memory for tables */ - vector_list = auto_alloc_array(machine, point, MAX_POINTS); + return m_beam_width; } @@ -190,32 +185,32 @@ VIDEO_START( vector ) * Adds a line end point to the vertices list. The vector processor emulation * needs to call this. */ -void vector_add_point (running_machine &machine, 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; if (intensity > 0xff) intensity = 0xff; - if (flicker && (intensity > 0)) + if (m_flicker && (intensity > 0)) { - intensity += (intensity * (0x80-(machine.rand()&0xff)) * flicker)>>16; + intensity += (intensity * (0x80-(machine().rand()&0xff)) * m_flicker)>>16; if (intensity < 0) intensity = 0; if (intensity > 0xff) intensity = 0xff; } - newpoint = &vector_list[vector_index]; + newpoint = &m_vector_list[m_vector_index]; newpoint->x = x; newpoint->y = y; newpoint->col = color; newpoint->intensity = intensity; newpoint->status = VDIRTY; /* mark identical lines as clean later */ - vector_index++; - if (vector_index >= MAX_POINTS) + m_vector_index++; + if (m_vector_index >= MAX_POINTS) { - vector_index--; + m_vector_index--; logerror("*** Warning! Vector list overflow!\n"); } } @@ -223,21 +218,21 @@ void vector_add_point (running_machine &machine, int x, int y, rgb_t color, int /* * Add new clipping info to the list */ -void vector_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; - newpoint = &vector_list[vector_index]; + newpoint = &m_vector_list[m_vector_index]; newpoint->x = x1; newpoint->y = yy1; newpoint->arg1 = x2; newpoint->arg2 = y2; newpoint->status = VCLIP; - vector_index++; - if (vector_index >= MAX_POINTS) + m_vector_index++; + if (m_vector_index >= MAX_POINTS) { - vector_index--; + m_vector_index--; logerror("*** Warning! Vector list overflow!\n"); } } @@ -247,13 +242,13 @@ void vector_add_clip (int x1, int yy1, int x2, int y2) * The vector CPU creates a new display list. We save the old display list, * but only once per refresh. */ -void vector_clear_list (void) +void vector_device::clear_list (void) { - vector_index = 0; + m_vector_index = 0; } -SCREEN_UPDATE_RGB32( vector ) +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); const rectangle &visarea = screen.visible_area(); @@ -266,7 +261,7 @@ SCREEN_UPDATE_RGB32( vector ) int lastx = 0, lasty = 0; int i; - curpoint = vector_list; + curpoint = m_vector_list; screen.container().empty(); screen.container().add_rect(0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0x00,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_VECTORBUF(1)); @@ -274,7 +269,7 @@ SCREEN_UPDATE_RGB32( vector ) clip.x0 = clip.y0 = 0.0f; clip.x1 = clip.y1 = 1.0f; - for (i = 0; i < vector_index; i++) + for (i = 0; i < m_vector_index; i++) { render_bounds coords; @@ -300,7 +295,7 @@ SCREEN_UPDATE_RGB32( vector ) if (curpoint->intensity != 0) if (!render_clip_line(&coords, &clip)) screen.container().add_line(coords.x0, coords.y0, coords.x1, coords.y1, - beam_width * (1.0f / (float)VECTOR_WIDTH_DENOM), + m_beam_width * (1.0f / (float)VECTOR_WIDTH_DENOM), (curpoint->intensity << 24) | (curpoint->col & 0xffffff), flags); diff --git a/src/emu/video/vector.h b/src/emu/video/vector.h index da00a4c67ab..9c0122b0250 100644 --- a/src/emu/video/vector.h +++ b/src/emu/video/vector.h @@ -9,18 +9,64 @@ #define VECTOR_COLOR444(c) \ MAKE_RGB(pal4bit((c) >> 8), pal4bit((c) >> 4), pal4bit((c) >> 0)) + -VIDEO_START( vector ); -SCREEN_UPDATE_RGB32( vector ); +/* The vertices are buffered here */ +struct point +{ + point(): + x(0), + y(0), + col(0), + intensity(0), + arg1(0), + arg2(0), + status(0) {} + + int x; int y; + rgb_t col; + int intensity; + int arg1; int arg2; /* start/end in pixel array or clipping info */ + int status; /* for dirty and clipping handling */ +}; + +class vector_device : public device_t, + public device_video_interface +{ -void vector_clear_list(void); -void vector_add_point(running_machine &machine, int x, int y, rgb_t color, int intensity); -void vector_add_clip(int minx, int miny, int maxx, int maxy); +public: + // construction/destruction + vector_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + vector_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); + + UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + void clear_list(); + + void add_point(int x, int y, rgb_t color, int intensity); + void add_clip(int minx, int miny, int maxx, int maxy); + + void set_flicker(float m_flicker_correction); + float get_flicker(); -void vector_set_flicker(float _flicker); -float vector_get_flicker(void); + void set_beam(float _beam); + float get_beam(); -void vector_set_beam(float _beam); -float vector_get_beam(void); + // device-level overrides + virtual void device_start(); + +private: + static int m_flicker; /* beam flicker value */ + static float m_flicker_correction; + static float m_beam_width; + point *m_vector_list; + static int m_vector_index; +}; + + +// device type definition +extern const device_type VECTOR; + +#define MCFG_VECTOR_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, VECTOR, 0) #endif |