summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Andrew Gardner <andrew.gardner@liu.se>2015-09-01 14:27:30 +0200
committer Andrew Gardner <andrew.gardner@liu.se>2015-09-01 14:27:30 +0200
commiteba313a1f287c52a82136f5cc65c035a6cbff6c2 (patch)
tree400fe2cb330786d830a690a7597b46bf3395cc79
parentc4a6be00168507365ddadf5d8ad58701341bc254 (diff)
Convert galastrm driver to render with the newer polygon interface instead of
the legacy one. (nw) This seems to work, and seems to adhere to the style of other "polynew" uses. If anyone sees anything totally wrong, let me know, because I will be slowly moving other drivers to "polynew" in the future.
-rw-r--r--src/mame/drivers/galastrm.c2
-rw-r--r--src/mame/includes/galastrm.h32
-rw-r--r--src/mame/video/galastrm.c147
3 files changed, 97 insertions, 84 deletions
diff --git a/src/mame/drivers/galastrm.c b/src/mame/drivers/galastrm.c
index e6329108fe9..c1be47a1737 100644
--- a/src/mame/drivers/galastrm.c
+++ b/src/mame/drivers/galastrm.c
@@ -252,7 +252,7 @@ static const gfx_layout tile16x16_layout =
{ 0, 8, 16, 24 },
{ 32, 33, 34, 35, 36, 37, 38, 39, 0, 1, 2, 3, 4, 5, 6, 7 },
{ 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
- 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
+ 8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
64*16 /* every sprite takes 128 consecutive bytes */
};
diff --git a/src/mame/includes/galastrm.h b/src/mame/includes/galastrm.h
index 5ac71d4cc79..b0b1ae6d4cf 100644
--- a/src/mame/includes/galastrm.h
+++ b/src/mame/includes/galastrm.h
@@ -1,10 +1,35 @@
// license:???
// copyright-holders:Hau
#include "machine/eepromser.h"
-#include "video/polylgcy.h"
+
+#include "video/poly.h"
#include "video/tc0100scn.h"
#include "video/tc0480scp.h"
+
+class galastrm_state;
+
+struct gs_poly_data
+{
+ bitmap_ind16* texbase;
+};
+
+class galastrm_renderer : public poly_manager<float, gs_poly_data, 2, 10000>
+{
+public:
+ galastrm_renderer(galastrm_state &state);
+
+ void tc0610_draw_scanline(INT32 scanline, const extent_t& extent, const gs_poly_data& object, int threadid);
+ void tc0610_rotate_draw(bitmap_ind16 &srcbitmap, const rectangle &clip);
+
+ bitmap_ind16 &screenbits() { return m_screenbits; }
+
+private:
+ galastrm_state& m_state;
+ bitmap_ind16 m_screenbits;
+};
+
+
struct gs_tempsprite
{
int gfx;
@@ -56,8 +81,8 @@ public:
struct gs_tempsprite *m_spritelist;
struct gs_tempsprite *m_sprite_ptr_pre;
bitmap_ind16 m_tmpbitmaps;
- bitmap_ind16 m_polybitmap;
- legacy_poly_manager *m_poly;
+ galastrm_renderer *m_poly;
+
int m_rsxb;
int m_rsyb;
int m_rsxoffs;
@@ -74,7 +99,6 @@ public:
virtual void video_start();
UINT32 screen_update_galastrm(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(galastrm_interrupt);
- void galastrm_exit();
void draw_sprites_pre(int x_offs, int y_offs);
void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, const int *primasks, int priority);
void tc0610_rotate_draw(bitmap_ind16 &bitmap, bitmap_ind16 &srcbitmap, const rectangle &clip);
diff --git a/src/mame/video/galastrm.c b/src/mame/video/galastrm.c
index d37ccb5bef3..c540a32cace 100644
--- a/src/mame/video/galastrm.c
+++ b/src/mame/video/galastrm.c
@@ -1,42 +1,41 @@
// license:???
// copyright-holders:Hau
#include "emu.h"
-#include "video/polylgcy.h"
#include "includes/galastrm.h"
#define X_OFFSET 96
#define Y_OFFSET 60
-struct gs_poly_extra_data
-{
- bitmap_ind16 *texbase;
-};
-
-struct polygon
+struct polyVert
{
float x;
float y;
float z;
};
-/******************************************************************/
-void galastrm_state::galastrm_exit()
+galastrm_renderer::galastrm_renderer(galastrm_state& state)
+ : poly_manager<float, gs_poly_data, 2, 10000>(state.machine())
+ , m_state(state)
+ , m_screenbits(state.m_screen->width(), state.m_screen->height())
{
- poly_free(m_poly);
+
}
+
+/******************************************************************/
+
void galastrm_state::video_start()
{
m_spritelist = auto_alloc_array(machine(), struct gs_tempsprite, 0x4000);
- m_screen->register_screen_bitmap(m_tmpbitmaps);
- m_screen->register_screen_bitmap(m_polybitmap);
+ m_poly = auto_alloc(machine(), galastrm_renderer(*this));
- m_poly = poly_alloc(machine(), 16, sizeof(gs_poly_extra_data), POLYFLAG_ALLOW_QUADS);
- machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(galastrm_state::galastrm_exit), this));
+ m_screen->register_screen_bitmap(m_tmpbitmaps);
+ m_screen->register_screen_bitmap(m_poly->screenbits());
}
+
/************************************************************
SPRITE DRAW ROUTINES
@@ -185,7 +184,7 @@ void galastrm_state::draw_sprites_pre(int x_offs, int y_offs)
m_sprite_ptr_pre++;
}
if (bad_chunks)
-logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks);
+ logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks);
}
}
@@ -215,46 +214,37 @@ void galastrm_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, c
POLYGON RENDERER
**************************************************************/
-static void tc0610_draw_scanline(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid)
+void galastrm_renderer::tc0610_draw_scanline(INT32 scanline, const extent_t& extent, const gs_poly_data& object, int threadid)
{
- const gs_poly_extra_data *extra = (const gs_poly_extra_data *)extradata;
- bitmap_ind16 *destmap = (bitmap_ind16 *)dest;
- UINT16 *framebuffer = &destmap->pix16(scanline);
- bitmap_ind16 *texbase = extra->texbase;
- int startx = extent->startx;
- int stopx = extent->stopx;
- INT32 u = extent->param[0].start;
- INT32 v = extent->param[1].start;
- INT32 dudx = extent->param[0].dpdx;
- INT32 dvdx = extent->param[1].dpdx;
- int x;
-
- for (x = startx; x < stopx; x++)
+ UINT16 *framebuffer = &m_screenbits.pix16(scanline);
+ const INT32 dudx = extent.param[0].dpdx;
+ const INT32 dvdx = extent.param[1].dpdx;
+
+ INT32 u = extent.param[0].start;
+ INT32 v = extent.param[1].start;
+ for (int x = extent.startx; x < extent.stopx; x++)
{
- framebuffer[x] = texbase->pix16(v >> 16, u >> 16);
+ framebuffer[x] = object.texbase->pix16(v >> 16, u >> 16);
u += dudx;
v += dvdx;
}
}
-void galastrm_state::tc0610_rotate_draw(bitmap_ind16 &bitmap, bitmap_ind16 &srcbitmap, const rectangle &clip)
+void galastrm_renderer::tc0610_rotate_draw(bitmap_ind16 &srcbitmap, const rectangle &clip)
{
- gs_poly_extra_data *extra = (gs_poly_extra_data *)poly_get_extra_data(m_poly);
- poly_draw_scanline_func callback;
- poly_vertex vert[4];
- int rsx = m_tc0610_ctrl_reg[1][0];
- int rsy = m_tc0610_ctrl_reg[1][1];
- const int rzx = m_tc0610_ctrl_reg[1][2];
- const int rzy = m_tc0610_ctrl_reg[1][3];
- const int ryx = m_tc0610_ctrl_reg[1][5];
- const int ryy = m_tc0610_ctrl_reg[1][4];
+ vertex_t vert[4];
+ int rsx = m_state.m_tc0610_ctrl_reg[1][0];
+ int rsy = m_state.m_tc0610_ctrl_reg[1][1];
+ const int rzx = m_state.m_tc0610_ctrl_reg[1][2];
+ const int rzy = m_state.m_tc0610_ctrl_reg[1][3];
+ const int ryx = m_state.m_tc0610_ctrl_reg[1][5];
+ const int ryy = m_state.m_tc0610_ctrl_reg[1][4];
const int lx = srcbitmap.width();
const int ly = srcbitmap.height();
int yx, /*yy,*/ zx, zy, pxx, pxy, pyx, pyy;
float /*ssn, scs, ysn, ycs,*/ zsn, zcs;
-
pxx = 0;
pxy = 0;
pyx = 0;
@@ -281,48 +271,48 @@ void galastrm_state::tc0610_rotate_draw(bitmap_ind16 &bitmap, bitmap_ind16 &srcb
zcs = ((float)pxx/4096.0f) / (float)(lx / 2);
- if ((rsx == -240 && rsy == 1072) || !m_tc0610_ctrl_reg[1][7])
+ if ((rsx == -240 && rsy == 1072) || !m_state.m_tc0610_ctrl_reg[1][7])
{
- m_rsxoffs = 0;
- m_rsyoffs = 0;
+ m_state.m_rsxoffs = 0;
+ m_state.m_rsyoffs = 0;
}
else
{
- if (rsx > m_rsxb && m_rsxb < 0 && rsx-m_rsxb > 0x8000)
+ if (rsx > m_state.m_rsxb && m_state.m_rsxb < 0 && rsx-m_state.m_rsxb > 0x8000)
{
- if (m_rsxoffs == 0)
- m_rsxoffs = -0x10000;
+ if (m_state.m_rsxoffs == 0)
+ m_state.m_rsxoffs = -0x10000;
else
- m_rsxoffs = 0;
+ m_state.m_rsxoffs = 0;
}
- if (rsx < m_rsxb && m_rsxb > 0 && m_rsxb-rsx > 0x8000)
+ if (rsx < m_state.m_rsxb && m_state.m_rsxb > 0 && m_state.m_rsxb-rsx > 0x8000)
{
- if (m_rsxoffs == 0)
- m_rsxoffs = 0x10000-1;
+ if (m_state.m_rsxoffs == 0)
+ m_state.m_rsxoffs = 0x10000-1;
else
- m_rsxoffs = 0;
+ m_state.m_rsxoffs = 0;
}
- if (rsy > m_rsyb && m_rsyb < 0 && rsy-m_rsyb > 0x8000)
+ if (rsy > m_state.m_rsyb && m_state.m_rsyb < 0 && rsy-m_state.m_rsyb > 0x8000)
{
- if (m_rsyoffs == 0)
- m_rsyoffs = -0x10000;
+ if (m_state.m_rsyoffs == 0)
+ m_state.m_rsyoffs = -0x10000;
else
- m_rsyoffs = 0;
+ m_state.m_rsyoffs = 0;
}
- if (rsy < m_rsyb && m_rsyb > 0 && m_rsyb-rsy > 0x8000)
+ if (rsy < m_state.m_rsyb && m_state.m_rsyb > 0 && m_state.m_rsyb-rsy > 0x8000)
{
- if (m_rsyoffs == 0)
- m_rsyoffs = 0x10000-1;
+ if (m_state.m_rsyoffs == 0)
+ m_state.m_rsyoffs = 0x10000-1;
else
- m_rsyoffs = 0;
+ m_state.m_rsyoffs = 0;
}
}
- m_rsxb = rsx;
- m_rsyb = rsy;
- if (m_rsxoffs) rsx += m_rsxoffs;
- if (m_rsyoffs) rsy += m_rsyoffs;
- if (rsx < -0x14000 || rsx >= 0x14000) m_rsxoffs = 0;
- if (rsy < -0x14000 || rsy >= 0x14000) m_rsyoffs = 0;
+ m_state.m_rsxb = rsx;
+ m_state.m_rsyb = rsy;
+ if (m_state.m_rsxoffs) rsx += m_state.m_rsxoffs;
+ if (m_state.m_rsyoffs) rsy += m_state.m_rsyoffs;
+ if (rsx < -0x14000 || rsx >= 0x14000) m_state.m_rsxoffs = 0;
+ if (rsy < -0x14000 || rsy >= 0x14000) m_state.m_rsyoffs = 0;
pxx = 0;
@@ -336,7 +326,7 @@ void galastrm_state::tc0610_rotate_draw(bitmap_ind16 &bitmap, bitmap_ind16 &srcb
//ysn = 0.0;
//ycs = 0.0;
- if (m_tc0610_ctrl_reg[1][7])
+ if (m_state.m_tc0610_ctrl_reg[1][7])
{
if (ryx != 0 || ryy != 0)
{
@@ -382,10 +372,8 @@ void galastrm_state::tc0610_rotate_draw(bitmap_ind16 &bitmap, bitmap_ind16 &srcb
//scs = ((float)pyy/65536.0) / (float)(ly / 2);
}
-
{
- polygon tmpz[4];
-
+ polyVert tmpz[4];
tmpz[0].x = ((float)(-zx) * zcs) - ((float)(-zy) * zsn);
tmpz[0].y = ((float)(-zx) * zsn) + ((float)(-zy) * zcs);
tmpz[0].z = 0.0;
@@ -399,7 +387,6 @@ void galastrm_state::tc0610_rotate_draw(bitmap_ind16 &bitmap, bitmap_ind16 &srcb
tmpz[3].y = ((float)(zx-1) * zsn) + ((float)(-zy) * zcs);
tmpz[3].z = 0.0;
-
vert[0].x = tmpz[0].x + (float)(lx / 2);
vert[0].y = tmpz[0].y + (float)(ly / 2);
vert[1].x = tmpz[1].x + (float)(lx / 2);
@@ -419,9 +406,11 @@ void galastrm_state::tc0610_rotate_draw(bitmap_ind16 &bitmap, bitmap_ind16 &srcb
vert[3].p[0] = (float)(lx - 1) * 65536.0f;
vert[3].p[1] = 0.0;
- extra->texbase = &srcbitmap;
- callback = tc0610_draw_scanline;
- poly_render_quad(m_poly, &bitmap, clip, callback, 2, &vert[0], &vert[1], &vert[2], &vert[3]);
+ gs_poly_data& extra = object_data_alloc();
+ extra.texbase = &srcbitmap;
+
+ render_polygon<4>(clip, render_delegate(FUNC(galastrm_renderer::tc0610_draw_scanline), this), 2, vert);
+ wait();
}
/**************************************************************
@@ -533,7 +522,7 @@ UINT32 galastrm_state::screen_update_galastrm(screen_device &screen, bitmap_ind1
{
pri = &priority_bitmap.pix8(y, x);
if (!(*pri & 0x02) && m_tmpbitmaps.pix16(y, x))
- *pri |= 0x04;
+ *pri |= 0x04;
}
}
}
@@ -541,10 +530,10 @@ UINT32 galastrm_state::screen_update_galastrm(screen_device &screen, bitmap_ind1
draw_sprites_pre(42-X_OFFSET, -571+Y_OFFSET);
draw_sprites(screen,m_tmpbitmaps,clip,primasks,1);
- copybitmap_trans(bitmap,m_polybitmap,0,0, 0,0,cliprect,0);
- m_polybitmap.fill(0, clip);
- tc0610_rotate_draw(m_polybitmap,m_tmpbitmaps,cliprect);
-
+ copybitmap_trans(bitmap, m_poly->screenbits(), 0,0, 0,0, cliprect, 0);
+ m_poly->screenbits().fill(0, clip);
+ m_poly->tc0610_rotate_draw(m_tmpbitmaps, cliprect);
+
priority_bitmap.fill(0, cliprect);
draw_sprites(screen,bitmap,cliprect,primasks,0);