Previous 15994 Revisions Next

r6697 Thursday 17th December, 2009 at 20:53:30 UTC by Barry Rodewald
[FMTOWNS] Fixed VRAM mapping, improvements to 16bpp graphic layer rendering.
[src/mess/drivers]fmtowns.c
[src/mess/video]fmtowns.c

src/mess/video/fmtowns.c
r6696r6697
552552
553553void towns_crtc_draw_scan_layer_hicolour(bitmap_t* bitmap,const rectangle* rect,int layer,int line,int scanline)
554554{
555   int off = 0;
555   UINT32 off = 0;
556556   int x;
557557   UINT16 colour;
558558   int hzoom = 1;
559   int linesize;
559560
560   if(towns_vram_page_sel != 0)
561      off = 0x20000;
561   if(layer == 0)
562      linesize = towns_crtc_reg[20] * 4;
563   else
564      linesize = towns_crtc_reg[24] * 4;
565
562566   if(layer != 0)
563567   {
564568      if(!(towns_video_reg[0] & 0x10))
565569         return;
566      off += 0x40000;
567      off += towns_crtc_reg[21];  // initial offset
570      off += (towns_crtc_reg[21] & 0xfffe) << 2;  // initial offset
568571      if(towns_crtc_reg[27] & 0x0100)
569572         hzoom = 2;
570573   }
571574   else
572575   {
573      off += towns_crtc_reg[17];  // initial offset
576      off += (towns_crtc_reg[17] & 0xfffe) << 2;  // initial offset
574577      if(towns_crtc_reg[27] & 0x0001)
575578         hzoom = 2;
576579   }
577580
578   off += (line * (512 / hzoom) * 2);
579
581   off += line * linesize;
582   
580583   if(hzoom == 1)
581584   {
582585      for(x=rect->min_x;x<rect->max_x;x++)
583586      {
584         colour = (towns_gfxvram[off] << 8) | towns_gfxvram[off+1];
585         if(colour != 0)
587         if(towns_video_reg[0] & 0x10)
588            off &= 0x3ffff;  // 2 layers
589         else
590            off &= 0x7ffff;  // 1 layer
591     
592         colour = (towns_gfxvram[off+(layer*0x40000)+1] << 8) | towns_gfxvram[off+(layer*0x40000)];
593         if(colour != 0 || colour >= 0x8000)
586594         {
587595            *BITMAP_ADDR32(bitmap,scanline,x) =
588               ((colour & 0xf800))
589               | ((colour & 0x07c0) << 13)
590               | ((colour & 0x003e) << 2);
596               ((colour & 0x001f) << 3)
597               | ((colour & 0x7c00) << 1)
598               | ((colour & 0x03e0) << 14);
591599         }
592600         off+=2;
593601      }
r6696r6697
596604   {  // x2 horizontal zoom
597605      for(x=rect->min_x;x<rect->max_x;x+=2)
598606      {
599         colour = (towns_gfxvram[off+1] << 8) | towns_gfxvram[off];
600         if(colour != 0)
607         if(towns_video_reg[0] & 0x10)
608            off &= 0x3ffff;  // 2 layers
609         else
610            off &= 0x7ffff;  // 1 layer
611         colour = (towns_gfxvram[off+(layer*0x40000)+1] << 8) | towns_gfxvram[off+(layer*0x40000)];
612         if(colour != 0 || colour >= 0x8000)
601613         {
602614            *BITMAP_ADDR32(bitmap,scanline,x) =
603615               ((colour & 0x001f) << 3)
r6696r6697
701713         hzoom = 2;
702714   }
703715
704   off += (line * ((rect->max_x - rect->min_x) / 2));
716   off += (line * ((rect->max_x - rect->min_x) / 2));  // offset at this scanline
705717
706718   if(hzoom == 1)
707719   {
r6696r6697
763775{
764776   int line;
765777   int scanline;
778   int height;
766779
767780   if(layer == 0)
768781   {
769782      scanline = rect->min_y;
783      height = (rect->max_y - rect->min_y);
784      if(towns_crtc_reg[27] & 0x0010)
785         height /= 2;
770786      switch(towns_video_reg[0] & 0x03)
771787      {
772788         case 0x01:
773            for(line=0;line<(rect->max_y - rect->min_y);line++)
789            for(line=0;line<height;line++)
774790            {
775791               towns_crtc_draw_scan_layer_16(bitmap,rect,layer,line,scanline);
776792               scanline++;
r6696r6697
782798            }
783799            break;
784800         case 0x02:
785            for(line=0;line<(rect->max_y - rect->min_y);line++)
801            for(line=0;line<height;line++)
786802            {
787803               towns_crtc_draw_scan_layer_256(bitmap,rect,layer,line,scanline);
788804               scanline++;
r6696r6697
794810            }
795811            break;
796812         case 0x03:
797            for(line=0;line<(rect->max_y - rect->min_y);line++)
813            for(line=0;line<height;line++)
798814            {
799815               towns_crtc_draw_scan_layer_hicolour(bitmap,rect,layer,line,scanline);
800816               scanline++;
r6696r6697
810826   else
811827   {
812828      scanline = rect->min_y;
829      height = (rect->max_y - rect->min_y);
830      if(towns_crtc_reg[27] & 0x1000)
831         height /= 2;
813832      switch(towns_video_reg[0] & 0x0c)
814833      {
815834         case 0x04:
816            for(line=rect->min_y;line<rect->max_y;line++)
835            for(line=0;line<height;line++)
817836            {
818837               towns_crtc_draw_scan_layer_16(bitmap,rect,layer,line,scanline);
819838               scanline++;
r6696r6697
825844            }
826845            break;
827846         case 0x08:
828            // 256 colour - TODO
847            for(line=0;line<height;line++)
848            {
849               towns_crtc_draw_scan_layer_256(bitmap,rect,layer,line,scanline);
850               scanline++;
851               if(towns_crtc_reg[27] & 0x1000)  // vertical zoom
852               {
853                  towns_crtc_draw_scan_layer_256(bitmap,rect,layer,line,scanline);
854                  scanline++;
855               }
856            }
829857            break;
830858         case 0x0c:
831            // Highcolour - TODO
859            for(line=0;line<height;line++)
860            {
861               towns_crtc_draw_scan_layer_hicolour(bitmap,rect,layer,line,scanline);
862               scanline++;
863               if(towns_crtc_reg[27] & 0x1000)  // vertical zoom
864               {
865                  towns_crtc_draw_scan_layer_hicolour(bitmap,rect,layer,line,scanline);
866                  scanline++;
867               }
868            }
832869            break;
833870      }
834871   }
r6696r6697
850887
851888   bitmap_fill(bitmap,cliprect,0x00000000);
852889
853   if(towns_video_reg[1] & 0x01)
890   if(!(towns_video_reg[1] & 0x01))
854891   {
855      towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1);
856      towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0);
892      if(!input_code_pressed(screen->machine,KEYCODE_Q))
893         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1);
894      if(!input_code_pressed(screen->machine,KEYCODE_W))
895         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0);
857896   }
858897   else
859898   {
860      towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0);
861      towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1);
899      if(!input_code_pressed(screen->machine,KEYCODE_Q))
900         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[0],0);
901      if(!input_code_pressed(screen->machine,KEYCODE_W))
902         towns_crtc_draw_layer(bitmap,&towns_crtc_layerscr[1],1);
862903   }
863904
864905
r6696r6697
935976   }
936977
937978#ifdef CRTC_REG_DISP
938   popmessage("CRTC: %i %i %i %i %i %i %i %i %i\n%i %i %i %i | %i %i %i %i\nZOOM: %04x\nShifter: %02x %02x\nText=%i",
979   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",
939980      towns_crtc_reg[0],towns_crtc_reg[1],towns_crtc_reg[2],towns_crtc_reg[3],
940981      towns_crtc_reg[4],towns_crtc_reg[5],towns_crtc_reg[6],towns_crtc_reg[7],
941982      towns_crtc_reg[8],
942983      towns_crtc_reg[9],towns_crtc_reg[10],towns_crtc_reg[11],towns_crtc_reg[12],
943984      towns_crtc_reg[13],towns_crtc_reg[14],towns_crtc_reg[15],towns_crtc_reg[16],
985      towns_crtc_reg[17],towns_crtc_reg[18],towns_crtc_reg[19],towns_crtc_reg[20],
986      towns_crtc_reg[21],towns_crtc_reg[22],towns_crtc_reg[23],towns_crtc_reg[24],
944987      towns_crtc_reg[27],towns_video_reg[0],towns_video_reg[1],towns_tvram_enable);
945988#endif
946989
src/mess/drivers/fmtowns.c
r6696r6697
16021602  AM_RANGE(0x000f0000, 0x000f7fff) AM_RAM //READWRITE(SMH_BANK(12),SMH_BANK(12))
16031603  AM_RANGE(0x000f8000, 0x000fffff) AM_READ_BANK("bank11") AM_WRITE_BANK("bank12")
16041604  AM_RANGE(0x00100000, 0x005fffff) AM_RAM  // some extra RAM - seems to be needed to boot
1605  AM_RANGE(0x80000000, 0x8003ffff) AM_READWRITE8(towns_gfx_high_r,towns_gfx_high_w,0xffffffff) AM_MIRROR(0x1c0000) // VRAM
1605  AM_RANGE(0x80000000, 0x8007ffff) AM_READWRITE8(towns_gfx_high_r,towns_gfx_high_w,0xffffffff) AM_MIRROR(0x180000) // VRAM
16061606  AM_RANGE(0x81000000, 0x8101ffff) AM_RAM  // Sprite RAM
16071607  AM_RANGE(0xc2000000, 0xc207ffff) AM_ROM AM_REGION("user",0x000000)  // OS ROM
16081608  AM_RANGE(0xc2080000, 0xc20fffff) AM_ROM AM_REGION("user",0x100000)  // DIC ROM
r6696r6697
16281628  AM_RANGE(0x00100000, 0x005fffff) AM_RAM  // some extra RAM - seems to be needed to boot
16291629  AM_RANGE(0x00600000, 0x0067ffff) AM_ROM AM_REGION("user",0x000000)  // OS
16301630  AM_RANGE(0x00680000, 0x0087ffff) AM_ROM AM_REGION("user",0x280000)  // EX ROM
1631  AM_RANGE(0x00a00000, 0x00a3ffff) AM_READWRITE8(towns_gfx_high_r,towns_gfx_high_w,0xffffffff) AM_MIRROR(0x1c0000) // VRAM
1631  AM_RANGE(0x00a00000, 0x00a7ffff) AM_READWRITE8(towns_gfx_high_r,towns_gfx_high_w,0xffffffff) AM_MIRROR(0x180000) // VRAM
16321632  AM_RANGE(0x00e80000, 0x00efffff) AM_ROM AM_REGION("user",0x100000)  // DIC ROM
16331633  AM_RANGE(0x00f00000, 0x00f7ffff) AM_ROM AM_REGION("user",0x180000)  // FONT
16341634  AM_RANGE(0x00fc0000, 0x00ffffff) AM_ROM AM_REGION("user",0x200000)  // SYSTEM ROM
1635  AM_RANGE(0x80000000, 0x8003ffff) AM_READWRITE8(towns_gfx_high_r,towns_gfx_high_w,0xffffffff) AM_MIRROR(0x1c0000) // VRAM
1635  AM_RANGE(0x80000000, 0x8007ffff) AM_READWRITE8(towns_gfx_high_r,towns_gfx_high_w,0xffffffff) AM_MIRROR(0x180000) // VRAM
16361636  AM_RANGE(0x81000000, 0x8101ffff) AM_RAM  // Sprite RAM
16371637  AM_RANGE(0xc2000000, 0xc207ffff) AM_ROM AM_REGION("user",0x000000)  // OS ROM
16381638  AM_RANGE(0xc2080000, 0xc20fffff) AM_ROM AM_REGION("user",0x100000)  // DIC ROM

Previous 15994 Revisions Next


© 1998-2018 The MESS Team