Previous 199869 Revisions Next

r40570 Tuesday 1st September, 2015 at 12:27:30 UTC by Andrew Gardner
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.
[src/mame/drivers]galastrm.c
[src/mame/includes]galastrm.h
[src/mame/video]galastrm.c

trunk/src/mame/drivers/galastrm.c
r249081r249082
252252   { 0, 8, 16, 24 },
253253   { 32, 33, 34, 35, 36, 37, 38, 39, 0, 1, 2, 3, 4, 5, 6, 7 },
254254   { 0*64, 1*64,  2*64,  3*64,  4*64,  5*64,  6*64,  7*64,
255      8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
255     8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
256256   64*16   /* every sprite takes 128 consecutive bytes */
257257};
258258
trunk/src/mame/includes/galastrm.h
r249081r249082
11// license:???
22// copyright-holders:Hau
33#include "machine/eepromser.h"
4#include "video/polylgcy.h"
4
5#include "video/poly.h"
56#include "video/tc0100scn.h"
67#include "video/tc0480scp.h"
78
9
10class galastrm_state;
11
12struct gs_poly_data
13{
14   bitmap_ind16* texbase;
15};
16
17class galastrm_renderer : public poly_manager<float, gs_poly_data, 2, 10000>
18{
19public:
20   galastrm_renderer(galastrm_state &state);
21
22    void tc0610_draw_scanline(INT32 scanline, const extent_t& extent, const gs_poly_data& object, int threadid);
23    void tc0610_rotate_draw(bitmap_ind16 &srcbitmap, const rectangle &clip);
24   
25    bitmap_ind16 &screenbits() { return m_screenbits; }
26   
27private:
28   galastrm_state& m_state;
29    bitmap_ind16 m_screenbits;
30};
31
32
833struct gs_tempsprite
934{
1035   int gfx;
r249081r249082
5681   struct gs_tempsprite *m_spritelist;
5782   struct gs_tempsprite *m_sprite_ptr_pre;
5883   bitmap_ind16 m_tmpbitmaps;
59   bitmap_ind16 m_polybitmap;
60   legacy_poly_manager *m_poly;
84    galastrm_renderer *m_poly;
85   
6186   int m_rsxb;
6287   int m_rsyb;
6388   int m_rsxoffs;
r249081r249082
7499   virtual void video_start();
75100   UINT32 screen_update_galastrm(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
76101   INTERRUPT_GEN_MEMBER(galastrm_interrupt);
77   void galastrm_exit();
78102   void draw_sprites_pre(int x_offs, int y_offs);
79103   void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, const int *primasks, int priority);
80104   void tc0610_rotate_draw(bitmap_ind16 &bitmap, bitmap_ind16 &srcbitmap, const rectangle &clip);
trunk/src/mame/video/galastrm.c
r249081r249082
11// license:???
22// copyright-holders:Hau
33#include "emu.h"
4#include "video/polylgcy.h"
54#include "includes/galastrm.h"
65
76#define X_OFFSET 96
87#define Y_OFFSET 60
98
10struct gs_poly_extra_data
9struct polyVert
1110{
12   bitmap_ind16 *texbase;
13};
14
15struct polygon
16{
1711   float x;
1812   float y;
1913   float z;
2014};
2115
22/******************************************************************/
2316
24void galastrm_state::galastrm_exit()
17galastrm_renderer::galastrm_renderer(galastrm_state& state)
18    : poly_manager<float, gs_poly_data, 2, 10000>(state.machine())
19    , m_state(state)
20    , m_screenbits(state.m_screen->width(), state.m_screen->height())
2521{
26   poly_free(m_poly);
22   
2723}
2824
25
26/******************************************************************/
27
2928void galastrm_state::video_start()
3029{
3130   m_spritelist = auto_alloc_array(machine(), struct gs_tempsprite, 0x4000);
3231
33   m_screen->register_screen_bitmap(m_tmpbitmaps);
34   m_screen->register_screen_bitmap(m_polybitmap);
32    m_poly = auto_alloc(machine(), galastrm_renderer(*this));
3533
36   m_poly = poly_alloc(machine(), 16, sizeof(gs_poly_extra_data), POLYFLAG_ALLOW_QUADS);
37   machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(galastrm_state::galastrm_exit), this));
34    m_screen->register_screen_bitmap(m_tmpbitmaps);
35    m_screen->register_screen_bitmap(m_poly->screenbits());
3836}
3937
38
4039/************************************************************
4140            SPRITE DRAW ROUTINES
4241
r249081r249082
185184         m_sprite_ptr_pre++;
186185      }
187186      if (bad_chunks)
188logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks);
187            logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks);
189188   }
190189}
191190
r249081r249082
215214                POLYGON RENDERER
216215**************************************************************/
217216
218static void tc0610_draw_scanline(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid)
217void galastrm_renderer::tc0610_draw_scanline(INT32 scanline, const extent_t& extent, const gs_poly_data& object, int threadid)
219218{
220   const gs_poly_extra_data *extra = (const gs_poly_extra_data *)extradata;
221   bitmap_ind16 *destmap = (bitmap_ind16 *)dest;
222   UINT16 *framebuffer = &destmap->pix16(scanline);
223   bitmap_ind16 *texbase = extra->texbase;
224   int startx = extent->startx;
225   int stopx = extent->stopx;
226   INT32 u = extent->param[0].start;
227   INT32 v = extent->param[1].start;
228   INT32 dudx = extent->param[0].dpdx;
229   INT32 dvdx = extent->param[1].dpdx;
230   int x;
219    UINT16 *framebuffer = &m_screenbits.pix16(scanline);
220   const INT32 dudx = extent.param[0].dpdx;
221   const INT32 dvdx = extent.param[1].dpdx;
231222
232   for (x = startx; x < stopx; x++)
223    INT32 u = extent.param[0].start;
224   INT32 v = extent.param[1].start;
225   for (int x = extent.startx; x < extent.stopx; x++)
233226   {
234      framebuffer[x] = texbase->pix16(v >> 16, u >> 16);
227      framebuffer[x] = object.texbase->pix16(v >> 16, u >> 16);
235228      u += dudx;
236229      v += dvdx;
237230   }
238231}
239232
240void galastrm_state::tc0610_rotate_draw(bitmap_ind16 &bitmap, bitmap_ind16 &srcbitmap, const rectangle &clip)
233void galastrm_renderer::tc0610_rotate_draw(bitmap_ind16 &srcbitmap, const rectangle &clip)
241234{
242   gs_poly_extra_data *extra = (gs_poly_extra_data *)poly_get_extra_data(m_poly);
243   poly_draw_scanline_func callback;
244   poly_vertex vert[4];
245   int rsx = m_tc0610_ctrl_reg[1][0];
246   int rsy = m_tc0610_ctrl_reg[1][1];
247   const int rzx = m_tc0610_ctrl_reg[1][2];
248   const int rzy = m_tc0610_ctrl_reg[1][3];
249   const int ryx = m_tc0610_ctrl_reg[1][5];
250   const int ryy = m_tc0610_ctrl_reg[1][4];
235   vertex_t vert[4];
236   int rsx = m_state.m_tc0610_ctrl_reg[1][0];
237   int rsy = m_state.m_tc0610_ctrl_reg[1][1];
238   const int rzx = m_state.m_tc0610_ctrl_reg[1][2];
239   const int rzy = m_state.m_tc0610_ctrl_reg[1][3];
240   const int ryx = m_state.m_tc0610_ctrl_reg[1][5];
241   const int ryy = m_state.m_tc0610_ctrl_reg[1][4];
251242   const int lx  = srcbitmap.width();
252243   const int ly  = srcbitmap.height();
253244
254245   int yx, /*yy,*/ zx, zy, pxx, pxy, pyx, pyy;
255246   float /*ssn, scs, ysn, ycs,*/ zsn, zcs;
256247
257
258248   pxx = 0;
259249   pxy = 0;
260250   pyx = 0;
r249081r249082
281271   zcs = ((float)pxx/4096.0f) / (float)(lx / 2);
282272
283273
284   if ((rsx == -240 && rsy == 1072) || !m_tc0610_ctrl_reg[1][7])
274   if ((rsx == -240 && rsy == 1072) || !m_state.m_tc0610_ctrl_reg[1][7])
285275   {
286      m_rsxoffs = 0;
287      m_rsyoffs = 0;
276      m_state.m_rsxoffs = 0;
277      m_state.m_rsyoffs = 0;
288278   }
289279   else
290280   {
291      if (rsx > m_rsxb && m_rsxb < 0 && rsx-m_rsxb > 0x8000)
281      if (rsx > m_state.m_rsxb && m_state.m_rsxb < 0 && rsx-m_state.m_rsxb > 0x8000)
292282      {
293         if (m_rsxoffs == 0)
294            m_rsxoffs = -0x10000;
283         if (m_state.m_rsxoffs == 0)
284            m_state.m_rsxoffs = -0x10000;
295285         else
296            m_rsxoffs = 0;
286            m_state.m_rsxoffs = 0;
297287      }
298      if (rsx < m_rsxb && m_rsxb > 0 && m_rsxb-rsx > 0x8000)
288      if (rsx < m_state.m_rsxb && m_state.m_rsxb > 0 && m_state.m_rsxb-rsx > 0x8000)
299289      {
300         if (m_rsxoffs == 0)
301            m_rsxoffs = 0x10000-1;
290         if (m_state.m_rsxoffs == 0)
291            m_state.m_rsxoffs = 0x10000-1;
302292         else
303            m_rsxoffs = 0;
293            m_state.m_rsxoffs = 0;
304294      }
305      if (rsy > m_rsyb && m_rsyb < 0 && rsy-m_rsyb > 0x8000)
295      if (rsy > m_state.m_rsyb && m_state.m_rsyb < 0 && rsy-m_state.m_rsyb > 0x8000)
306296      {
307         if (m_rsyoffs == 0)
308            m_rsyoffs = -0x10000;
297         if (m_state.m_rsyoffs == 0)
298            m_state.m_rsyoffs = -0x10000;
309299         else
310            m_rsyoffs = 0;
300            m_state.m_rsyoffs = 0;
311301      }
312      if (rsy < m_rsyb && m_rsyb > 0 && m_rsyb-rsy > 0x8000)
302      if (rsy < m_state.m_rsyb && m_state.m_rsyb > 0 && m_state.m_rsyb-rsy > 0x8000)
313303      {
314         if (m_rsyoffs == 0)
315            m_rsyoffs = 0x10000-1;
304         if (m_state.m_rsyoffs == 0)
305            m_state.m_rsyoffs = 0x10000-1;
316306         else
317            m_rsyoffs = 0;
307            m_state.m_rsyoffs = 0;
318308      }
319309   }
320   m_rsxb = rsx;
321   m_rsyb = rsy;
322   if (m_rsxoffs) rsx += m_rsxoffs;
323   if (m_rsyoffs) rsy += m_rsyoffs;
324   if (rsx < -0x14000 || rsx >= 0x14000) m_rsxoffs = 0;
325   if (rsy < -0x14000 || rsy >= 0x14000) m_rsyoffs = 0;
310   m_state.m_rsxb = rsx;
311   m_state.m_rsyb = rsy;
312   if (m_state.m_rsxoffs) rsx += m_state.m_rsxoffs;
313   if (m_state.m_rsyoffs) rsy += m_state.m_rsyoffs;
314   if (rsx < -0x14000 || rsx >= 0x14000) m_state.m_rsxoffs = 0;
315   if (rsy < -0x14000 || rsy >= 0x14000) m_state.m_rsyoffs = 0;
326316
327317
328318   pxx = 0;
r249081r249082
336326   //ysn = 0.0;
337327   //ycs = 0.0;
338328
339   if (m_tc0610_ctrl_reg[1][7])
329   if (m_state.m_tc0610_ctrl_reg[1][7])
340330   {
341331      if (ryx != 0 || ryy != 0)
342332      {
r249081r249082
382372      //scs = ((float)pyy/65536.0) / (float)(ly / 2);
383373   }
384374
385
386375   {
387      polygon tmpz[4];
388
376      polyVert tmpz[4];
389377      tmpz[0].x = ((float)(-zx)  * zcs) - ((float)(-zy)  * zsn);
390378      tmpz[0].y = ((float)(-zx)  * zsn) + ((float)(-zy)  * zcs);
391379      tmpz[0].z = 0.0;
r249081r249082
399387      tmpz[3].y = ((float)(zx-1) * zsn) + ((float)(-zy)  * zcs);
400388      tmpz[3].z = 0.0;
401389
402
403390      vert[0].x = tmpz[0].x + (float)(lx / 2);
404391      vert[0].y = tmpz[0].y + (float)(ly / 2);
405392      vert[1].x = tmpz[1].x + (float)(lx / 2);
r249081r249082
419406   vert[3].p[0] = (float)(lx - 1) * 65536.0f;
420407   vert[3].p[1] = 0.0;
421408
422   extra->texbase = &srcbitmap;
423   callback = tc0610_draw_scanline;
424   poly_render_quad(m_poly, &bitmap, clip, callback, 2, &vert[0], &vert[1], &vert[2], &vert[3]);
409    gs_poly_data& extra = object_data_alloc();
410    extra.texbase = &srcbitmap;
411   
412    render_polygon<4>(clip, render_delegate(FUNC(galastrm_renderer::tc0610_draw_scanline), this), 2, vert);
413    wait();
425414}
426415
427416/**************************************************************
r249081r249082
533522         {
534523            pri = &priority_bitmap.pix8(y, x);
535524            if (!(*pri & 0x02) && m_tmpbitmaps.pix16(y, x))
536                  *pri |= 0x04;
525               *pri |= 0x04;
537526         }
538527      }
539528   }
r249081r249082
541530   draw_sprites_pre(42-X_OFFSET, -571+Y_OFFSET);
542531   draw_sprites(screen,m_tmpbitmaps,clip,primasks,1);
543532
544   copybitmap_trans(bitmap,m_polybitmap,0,0, 0,0,cliprect,0);
545   m_polybitmap.fill(0, clip);
546   tc0610_rotate_draw(m_polybitmap,m_tmpbitmaps,cliprect);
547
533    copybitmap_trans(bitmap, m_poly->screenbits(), 0,0, 0,0, cliprect, 0);
534   m_poly->screenbits().fill(0, clip);
535    m_poly->tc0610_rotate_draw(m_tmpbitmaps, cliprect);
536   
548537   priority_bitmap.fill(0, cliprect);
549538   draw_sprites(screen,bitmap,cliprect,primasks,0);
550539


Previous 199869 Revisions Next


© 1997-2024 The MAME Team