Previous 15994 Revisions Next

r7603 Friday 19th March, 2010 at 01:42:36 UTC by Barry Rodewald
[FMTOWNS] Improved sprite clipping.
[src/mess/video]fmtowns.c

src/mess/video/fmtowns.c
r7602r7603
125125extern UINT32 towns_mainmem_enable;
126126extern UINT32 towns_ankcg_enable;
127127
128static UINT32 pshift;  // for debugging
128//static UINT32 pshift;  // for debugging
129129
130130void towns_crtc_refresh_mode(running_machine* machine)
131131{
r7602r7603
682682 */
683683void render_sprite_4(UINT32 poffset, UINT32 coffset, UINT16 x, UINT16 y, UINT16 xflip, UINT16 yflip, const rectangle* rect)
684684{
685   INT16 xpos,ypos;
685   UINT16 xpos,ypos;
686686   UINT16 col,pixel;
687687   UINT32 voffset;
688   int xstart,xend,xdir,ystart,yend,ydir;
688   UINT16 xstart,xend,ystart,yend;
689   int xdir,ydir;
690   int width = (towns_crtc_reg[12] - towns_crtc_reg[11]) / (((towns_crtc_reg[27] & 0x0f00) >> 8)+1);
691   int height = (towns_crtc_reg[16] - towns_crtc_reg[15]) / (((towns_crtc_reg[27] & 0xf000) >> 12)+1);
689692
690693   if(xflip)
691694   {
r7602r7603
711714      yend = y+16;
712715      ydir = 1;
713716   }
717   xstart &= 0x1ff;
718   xend &= 0x1ff;
719   ystart &= 0x1ff;
720   yend &= 0x1ff;
721   poffset &= 0x1ffff;
714722
715   for(ypos=ystart;ypos!=yend;ypos+=ydir)
723   for(ypos=ystart;ypos!=yend;ypos+=ydir,ypos&=0x1ff)
716724   {
717      for(xpos=xstart;xpos!=xend;xpos+=xdir)
725      for(xpos=xstart;xpos!=xend;xpos+=xdir,xpos&=0x1ff)
718726      {
719727         voffset = 0;
720728         pixel = (towns_txtvram[poffset] & 0xf0) >> 4;
r7602r7603
723731         voffset += (xpos & 0x1ff) * 2;
724732         voffset &= 0x3ffff;
725733         voffset += (towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000;
726         if(xpos <= rect->max_x && ypos <= rect->max_y && pixel != 0)
734         if(xpos < width && ypos < height && pixel != 0)
727735         {
728736            towns_gfxvram[voffset+1] = (col & 0xff00) >> 8;
729737            towns_gfxvram[voffset] = col & 0x00ff;
r7602r7603
736744         col = towns_txtvram[coffset+(pixel*2)] | (towns_txtvram[coffset+(pixel*2)+1] << 8);
737745         voffset &= 0x3ffff;
738746         voffset += (towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000;
739         if(xpos <= rect->max_x && ypos <= rect->max_y && pixel != 0)
747         if(xpos < width && ypos < height && pixel != 0)
740748         {
741749            towns_gfxvram[voffset+1] = (col & 0xff00) >> 8;
742750            towns_gfxvram[voffset] = col & 0x00ff;
743751         }
744752         poffset++;
753         poffset &= 0x1ffff;
745754      }
746755   }
747756}
748757
749758void render_sprite_16(UINT32 poffset, UINT16 x, UINT16 y, UINT16 xflip, UINT16 yflip, const rectangle* rect)
750759{
751   INT16 xpos,ypos;
760   UINT16 xpos,ypos;
752761   UINT16 col;
753762   UINT32 voffset;
754   int xstart,ystart,xend,yend,xdir,ydir;
763   UINT16 xstart,ystart,xend,yend;
764   int xdir,ydir;
765   int width = (towns_crtc_reg[12] - towns_crtc_reg[11]) / (((towns_crtc_reg[27] & 0x0f00) >> 8)+1);
766   int height = (towns_crtc_reg[16] - towns_crtc_reg[15]) / (((towns_crtc_reg[27] & 0xf000) >> 12)+1);
755767
756768   if(xflip)
757769   {
r7602r7603
777789      yend = y+16;
778790      ydir = 1;
779791   }
792   xstart &= 0x1ff;
793   xend &= 0x1ff;
794   ystart &= 0x1ff;
795   yend &= 0x1ff;
796   poffset &= 0x1ffff;
780797
781   for(ypos=ystart;ypos!=yend;ypos+=ydir)
798   for(ypos=ystart;ypos!=yend;ypos+=ydir,ypos&=0x1ff)
782799   {
783      for(xpos=xstart;xpos!=xend;xpos+=xdir)
800      for(xpos=xstart;xpos!=xend;xpos+=xdir,xpos&=0x1ff)
784801      {
785802         voffset = (towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000;
786803         col = towns_txtvram[poffset] | (towns_txtvram[poffset+1] << 8);
787804         voffset += (towns_crtc_reg[24] * 4) * ypos;  // scanline size in bytes * y pos
788805         voffset += (xpos & 0x1ff) * 2;
789806         voffset &= 0x7ffff;
790         if(xpos <= rect->max_x && ypos <= rect->max_y && col < 0x8000)
807         if(xpos < width && ypos < height && col < 0x8000)
791808         {
792809            towns_gfxvram[voffset+1] = (col & 0xff00) >> 8;
793810            towns_gfxvram[voffset] = col & 0x00ff;
794811         }
795812         poffset+=2;
813         poffset &= 0x1ffff;
796814      }
797815   }
798816}
r7602r7603
831849         poffset = (attr & 0x3ff) << 7;
832850         coffset = (colour & 0xfff) << 5;
833851#ifdef SPR_DEBUG
834         printf("Sprite4 #%i, X %i Y %i Attr %04x Col %04x Poff %05x Coff %05x\n",
852         printf("Sprite4 #%i, X %i Y %i Attr %04x Col %04x Poff %08x Coff %08x\n",
835853            n,x,y,attr,colour,poffset,coffset);
836854#endif
837855         if(!(colour & 0x2000))
838            render_sprite_4((poffset+pshift)&0x1ffff,coffset,x,y,attr&0x2000,attr&0x1000,rect);
856            render_sprite_4((poffset)&0x1ffff,coffset,x,y,attr&0x2000,attr&0x1000,rect);
839857      }
840858      else
841859      {
842860         poffset = (attr & 0x3ff) << 7;
843861         coffset = (colour & 0xfff) << 5;
844862#ifdef SPR_DEBUG
845         printf("Sprite16 #%i, X %i Y %i Attr %04x Col %04x Poff %05x Coff %05x\n",
863         printf("Sprite16 #%i, X %i Y %i Attr %04x Col %04x Poff %08x Coff %08x\n",
846864            n,x,y,attr,colour,poffset,coffset);
847865#endif
848         render_sprite_16((poffset+pshift)&0x1ffff,x,y,attr&0x2000,attr&0x1000,rect);
866         if(!(colour & 0x2000))
867            render_sprite_16((poffset)&0x1ffff,x,y,attr&0x2000,attr&0x1000,rect);
849868      }
850869   }
851870}
r7602r7603
13401359         towns_crtc_draw_layer(screen->machine,bitmap,&towns_crtc_layerscr[1],1);
13411360   }
13421361
1343#ifdef SPR_DEBUG
1362/*#ifdef SPR_DEBUG
13441363   if(input_code_pressed(screen->machine,KEYCODE_O))
13451364      pshift+=0x80;
13461365   if(input_code_pressed(screen->machine,KEYCODE_I))
13471366      pshift-=0x80;
13481367   popmessage("Pixel shift = %08x",pshift);
1349#endif
1368#endif*/
13501369
13511370#ifdef CRTC_REG_DISP
13521371   popmessage("CRTC: %i %i %i %i %i %i %i %i %i\n%i %i %i %i | %i %i %i %i\n%i %i %i %i | %i %i %i %i\nZOOM: %04x\nVideo: %02x %02x\nText=%i Spr=%02x",

Previous 15994 Revisions Next


© 1998-2018 The MESS Team