Previous 199869 Revisions Next

r29475 Wednesday 9th April, 2014 at 04:51:39 UTC by Alex Jackson
namcona1.c: rewrite tilemap drawing, fixing MT 05499 [Alex Jackson]
[src/mame/video]namcona1.c

trunk/src/mame/video/namcona1.c
r29474r29475
265265   }
266266} /* namcona1_gfxram_w */
267267
268static void UpdateGfx(running_machine &machine)
269{
270} /* UpdateGfx */
271
272268void namcona1_state::video_start()
273269{
274270   m_roz_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(namcona1_state::roz_get_info),this), TILEMAP_SCAN_ROWS, 8,8,64,64 );
r29474r29475
537533
538534void namcona1_state::draw_background(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int which, int primask )
539535{
540   UINT16 *videoram = m_videoram;
541   /*          scrollx lineselect
542    *  tmap0   ffe000  ffe200
543    *  tmap1   ffe400  ffe600
544    *  tmap2   ffe800  ffea00
545    *  tmap3   ffec00  ffee00
546    */
547   int xadjust = 0x3a - which*2;
548   const UINT16 *scroll = m_scroll+0x200*which;
549   int line;
550   UINT16 xdata, ydata;
551   int scrollx, scrolly;
552   rectangle clip;
553   const pen_t *paldata;
554   gfx_element *pGfx;
555
556   pGfx = m_gfxdecode->gfx(0);
557   assert(which >= 0 && which < ARRAY_LENGTH(m_tilemap_palette_bank));
558   paldata = &m_palette->pen(pGfx->colorbase() + pGfx->granularity() * m_tilemap_palette_bank[which]);
559
560   /* draw one scanline at a time */
561   clip.min_x = cliprect.min_x;
562   clip.max_x = cliprect.max_x;
563   scrollx = 0;
564   scrolly = 0;
565   for( line=0; line<256; line++ )
536   if(which == NAMCONA1_NUM_TILEMAPS )
566537   {
567      clip.min_y = line;
568      clip.max_y = line;
569      xdata = scroll[line];
570      if( xdata )
571      {
572         /* screenwise linescroll */
573         scrollx = xadjust+xdata;
574      }
575      ydata = scroll[line+0x100];
576      if( ydata&0x4000 )
577      {
578         /* line select: dword offset from 0xff000 or tilemap source line */
579         scrolly = (ydata - line)&0x1ff;
580      }
538      /* draw roz all at once */
539      int incxx = ((INT16)m_vreg[0xc0/2])<<8;
540      int incxy = ((INT16)m_vreg[0xc2/2])<<8;
541      int incyx = ((INT16)m_vreg[0xc4/2])<<8;
542      int incyy = ((INT16)m_vreg[0xc6/2])<<8;
543      INT16 xoffset = m_vreg[0xc8/2];
544      INT16 yoffset = m_vreg[0xca/2];
545      int dx = 46; /* horizontal adjust */
546      int dy = -8; /* vertical adjust */
547      UINT32 startx = (xoffset<<12)+incxx*dx+incyx*dy;
548      UINT32 starty = (yoffset<<12)+incxy*dx+incyy*dy;
549      m_roz_tilemap->draw_roz(screen, bitmap, cliprect,
550         startx, starty, incxx, incxy, incyx, incyy, 0, 0, primask, 0);
551   }
552   else
553   {
554      /* draw one scanline at a time */
555      /*          scrollx lineselect
556      *  tmap0   ffe000  ffe200
557      *  tmap1   ffe400  ffe600
558      *  tmap2   ffe800  ffea00
559      *  tmap3   ffec00  ffee00
560      */
561      const UINT16 *scroll = &m_scroll[which * 0x400/2];
562      const pen_t *paldata = &m_palette->pen(m_tilemap_palette_bank[which] * 256);
563      rectangle clip = cliprect;
564      int xadjust = 0x3a - which*2;
565      int scrollx = 0;
566      int scrolly = 0;
581567
582      if (line >= cliprect.min_y && line <= cliprect.max_y)
568      for( int line = 0; line < 256; line++ )
583569      {
584         if( xdata == 0xc001 )
570         clip.min_y = line;
571         clip.max_y = line;
572         int xdata = scroll[line];
573         int ydata = scroll[line + 0x200/2];
574
575         if( xdata )
585576         {
586            /* This is a simplification, but produces the correct behavior for the only game that uses this
587             * feature, Numan Athletics.
588             */
589            draw_pixel_line(
590               &bitmap.pix16(line),
591               &screen.priority().pix8(line),
592               videoram + ydata + 25,
593               paldata );
577            /* screenwise linescroll */
578            scrollx = xadjust+xdata;
594579         }
595         else
580
581         if( ydata&0x4000 )
596582         {
597            if(which == NAMCONA1_NUM_TILEMAPS )
583            /* line select: dword offset from 0xff000 or tilemap source line */
584            scrolly = (ydata - line)&0x1ff;
585         }
586
587         if (line >= cliprect.min_y && line <= cliprect.max_y)
588         {
589            if( xdata == 0xc001 )
598590            {
599               int incxx = ((INT16)m_vreg[0xc0/2])<<8;
600               int incxy = ((INT16)m_vreg[0xc2/2])<<8;
601               int incyx = ((INT16)m_vreg[0xc4/2])<<8;
602               int incyy = ((INT16)m_vreg[0xc6/2])<<8;
603               INT16 xoffset = m_vreg[0xc8/2];
604               INT16 yoffset = m_vreg[0xca/2];
605               int dx = 46; /* horizontal adjust */
606               int dy = -8; /* vertical adjust */
607               UINT32 startx = (xoffset<<12)+incxx*dx+incyx*dy;
608               UINT32 starty = (yoffset<<12)+incxy*dx+incyy*dy;
609               m_roz_tilemap->draw_roz(screen, bitmap, clip,
610                  startx, starty, incxx, incxy, incyx, incyy, 0, 0, primask, 0);
591               /* This is a simplification, but produces the correct behavior for the only game that uses this
592               * feature, Numan Athletics.
593               */
594               draw_pixel_line(&bitmap.pix16(line),
595                        &screen.priority().pix8(line),
596                        m_videoram + ydata + 25,
597                        paldata );
611598            }
612599            else
613600            {
r29474r29475
638625         }
639626         m_palette_is_dirty = 0;
640627      }
641      UpdateGfx(machine());
628
642629      for( which=0; which<NAMCONA1_NUM_TILEMAPS; which++ )
643630      {
644631         int tilemap_color = m_vreg[0xb0/2+(which&3)]&0xf;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team