Previous 199869 Revisions Next

r17577 Thursday 30th August, 2012 at 09:13:16 UTC by Barry Rodewald
(MESS) svga_s3: Implemented pattern fills, fixed some BG/FG mix functions, fixed a bug when drawing wait rectangles in reverse direction.
[src/emu/video]pc_vga.c

trunk/src/emu/video/pc_vga.c
r17576r17577
27582758   switch(s3.fgmix & 0x000f)
27592759   {
27602760   case 0x0000:
2761      vga.memory[offset] = !dst;
2761      vga.memory[offset] = ~dst;
27622762      break;
27632763   case 0x0001:
2764      // TODO: false
2764      vga.memory[offset] = 0x00;  // is this correct?
27652765      break;
27662766   case 0x0002:
2767      // TODO: true
2767      vga.memory[offset] = 0xff;  // is this correct?
27682768      break;
27692769   case 0x0003:
27702770      // change nothing, pixel is unchanged
27712771      break;
27722772   case 0x0004:
2773      vga.memory[offset] = !src;
2773      vga.memory[offset] = ~src;
27742774      break;
27752775   case 0x0005:
27762776      vga.memory[offset] = src ^ dst;
27772777      break;
27782778   case 0x0006:
2779      vga.memory[offset] = !(src ^ dst);
2779      vga.memory[offset] = ~(src ^ dst);
27802780      break;
27812781   case 0x0007:
27822782      vga.memory[offset] = src;
27832783      break;
27842784   case 0x0008:
2785      vga.memory[offset] = !(src & dst);
2785      vga.memory[offset] = ~(src & dst);
27862786      break;
27872787   case 0x0009:
2788      vga.memory[offset] = (!src) | dst;
2788      vga.memory[offset] = (~src) | dst;
27892789      break;
27902790   case 0x000a:
2791      vga.memory[offset] = src | (!dst);
2791      vga.memory[offset] = src | (~dst);
27922792      break;
27932793   case 0x000b:
27942794      vga.memory[offset] = src | dst;
r17576r17577
27972797      vga.memory[offset] = src & dst;
27982798      break;
27992799   case 0x000d:
2800      vga.memory[offset] = src & (!dst);
2800      vga.memory[offset] = src & (~dst);
28012801      break;
28022802   case 0x000e:
2803      vga.memory[offset] = (!src) & dst;
2803      vga.memory[offset] = (~src) & dst;
28042804      break;
28052805   case 0x000f:
2806      vga.memory[offset] = !(src | dst);
2806      vga.memory[offset] = ~(src | dst);
28072807      break;
28082808   }
28092809}
r17576r17577
28332833   switch(s3.bgmix & 0x000f)
28342834   {
28352835   case 0x0000:
2836      vga.memory[offset] = !dst;
2836      vga.memory[offset] = ~dst;
28372837      break;
28382838   case 0x0001:
2839      // TODO: false
2839      vga.memory[offset] = 0x00;  // is this correct?
28402840      break;
28412841   case 0x0002:
2842      // TODO: true
2842      vga.memory[offset] = 0xff;  // is this correct?
28432843      break;
28442844   case 0x0003:
28452845      // change nothing, pixel is unchanged
28462846      break;
28472847   case 0x0004:
2848      vga.memory[offset] = !src;
2848      vga.memory[offset] = ~src;
28492849      break;
28502850   case 0x0005:
28512851      vga.memory[offset] = src ^ dst;
28522852      break;
28532853   case 0x0006:
2854      vga.memory[offset] = !(src ^ dst);
2854      vga.memory[offset] = ~(src ^ dst);
28552855      break;
28562856   case 0x0007:
28572857      vga.memory[offset] = src;
28582858      break;
28592859   case 0x0008:
2860      vga.memory[offset] = !(src & dst);
2860      vga.memory[offset] = ~(src & dst);
28612861      break;
28622862   case 0x0009:
2863      vga.memory[offset] = (!src) | dst;
2863      vga.memory[offset] = (~src) | dst;
28642864      break;
28652865   case 0x000a:
2866      vga.memory[offset] = src | (!dst);
2866      vga.memory[offset] = src | (~dst);
28672867      break;
28682868   case 0x000b:
28692869      vga.memory[offset] = src | dst;
r17576r17577
28722872      vga.memory[offset] = src & dst;
28732873      break;
28742874   case 0x000d:
2875      vga.memory[offset] = src & (!dst);
2875      vga.memory[offset] = src & (~dst);
28762876      break;
28772877   case 0x000e:
2878      vga.memory[offset] = (!src) & dst;
2878      vga.memory[offset] = (~src) & dst;
28792879      break;
28802880   case 0x000f:
2881      vga.memory[offset] = !(src | dst);
2881      vga.memory[offset] = ~(src | dst);
28822882      break;
28832883   }
28842884}
r17576r17577
30063006   if(s3.enable_8514 != 0)
30073007   {
30083008      int x,y;
3009      int dir_x;
3010//      int pattern_x,pattern_y;
3009      int pattern_x,pattern_y;
30113010      UINT32 offset,src;
30123011
30133012      s3.current_cmd = data;
r17576r17577
30383037         offset = VGA_START_ADDRESS;
30393038         offset += (VGA_LINE_LENGTH * s3.curr_y);
30403039         offset += s3.curr_x;
3041         if(data & 0x0020)
3042            dir_x = 1;
3043         else
3044            dir_x = -1;
30453040         for(y=0;y<=s3.rect_height;y++)
30463041         {
3047            for(x=0;x<=s3.rect_width;x+=dir_x)
3042            for(x=0;x<=s3.rect_width;x++)
30483043            {
3049               s3_write_fg((offset+x) % vga.svga_intf.vram_size);
3044               if(data & 0x0020)
3045                  s3_write_fg((offset+x) % vga.svga_intf.vram_size);
3046               else
3047                  s3_write_fg((offset-x) % vga.svga_intf.vram_size);
30503048            }
30513049            if(data & 0x0080)
30523050               offset += VGA_LINE_LENGTH;
r17576r17577
30913089               s3.curr_x,s3.curr_y,s3.dest_x,s3.dest_y,s3.rect_width,s3.rect_height);
30923090         break;
30933091      case 0xe000:  // Pattern Fill
3094//         offset = VGA_START_ADDRESS;
3095//         offset += (VGA_LINE_LENGTH * s3.dest_y);
3096//         offset += s3.dest_x;
3097//         src = VGA_START_ADDRESS;
3098//         src += (VGA_LINE_LENGTH * s3.curr_y);
3099//         src += s3.curr_x;
3100//         pattern_x = pattern_y = 0;
3101//         for(y=0;y<=s3.rect_height;y++)
3102//         {
3103//            for(x=0;x<=s3.rect_width;x++)
3104//            {
3105//               if(data & 0x0020)
3106//                  vga.memory[(offset+x) % vga.svga_intf.vram_size] = vga.memory[(src+pattern_x) % vga.svga_intf.vram_size];
3107//               else
3108//                  vga.memory[(offset-x) % vga.svga_intf.vram_size] = vga.memory[(src-pattern_x) % vga.svga_intf.vram_size];
3109//               pattern_x++;
3110//               pattern_x %= 8;
3111//            }
3112//            pattern_y++;
3113//            src += VGA_LINE_LENGTH;
3114//            if(pattern_y % 8 == 0)
3115//               src -= (VGA_LINE_LENGTH * 8);  // move src pointer back to top of pattern
3116//            if(data & 0x0080)
3117//               offset += VGA_LINE_LENGTH;
3118//            else
3119//               offset -= VGA_LINE_LENGTH;
3120//         }
3092         offset = VGA_START_ADDRESS;
3093         offset += (VGA_LINE_LENGTH * s3.dest_y);
3094         offset += s3.dest_x;
3095         src = VGA_START_ADDRESS;
3096         src += (VGA_LINE_LENGTH * s3.curr_y);
3097         src += s3.curr_x;
3098         if(data & 0x0020)
3099            pattern_x = 0;
3100         else
3101            pattern_x = 7;
3102         if(data & 0x0080)
3103            pattern_y = 0;
3104         else
3105            pattern_y = 7;
3106
3107         for(y=0;y<=s3.rect_height;y++)
3108         {
3109            for(x=0;x<=s3.rect_width;x++)
3110            {
3111               if(data & 0x0020)
3112               {
3113                  if(vga.memory[(src+pattern_x) % vga.svga_intf.vram_size] == 0x00)
3114                     s3_write_fg(offset+x);
3115                  else
3116                     s3_write_bg(offset+x);
3117                  pattern_x++;
3118                  if(pattern_x >= 8)
3119                     pattern_x = 0;
3120               }
3121               else
3122               {
3123                  if(vga.memory[(src-pattern_x) % vga.svga_intf.vram_size] == 0x00)
3124                     s3_write_fg(offset-x);
3125                  else
3126                     s3_write_bg(offset-x);
3127                  pattern_x--;
3128                  if(pattern_x < 0)
3129                     pattern_x = 7;
3130               }
3131            }
3132
3133            // for now, presume that INC_X and INC_Y affect both src and dest, at is would for a bitblt.
3134            if(data & 0x0020)
3135               pattern_x = 0;
3136            else
3137               pattern_x = 7;
3138            if(data & 0x0080)
3139            {
3140               pattern_y++;
3141               src += VGA_LINE_LENGTH;
3142               if(pattern_y >= 8)
3143               {
3144                  pattern_y = 0;
3145                  src -= (VGA_LINE_LENGTH * 8);  // move src pointer back to top of pattern
3146               }
3147               offset += VGA_LINE_LENGTH;
3148            }
3149            else
3150            {
3151               pattern_y--;
3152               src -= VGA_LINE_LENGTH;
3153               if(pattern_y < 0)
3154               {
3155                  pattern_y = 7;
3156                  src += (VGA_LINE_LENGTH * 8);  // move src pointer back to bottom of pattern
3157               }
3158               offset -= VGA_LINE_LENGTH;
3159            }
3160         }
31213161         s3.state = S3_IDLE;
31223162         s3.gpbusy = false;
31233163         logerror("S3: Command (%04x) - Pattern Fill - source %i,%i  dest %i,%i  Width: %i Height: %i\n",s3.current_cmd,
r17576r17577
33783418               s3_write_bg(off % vga.svga_intf.vram_size);
33793419         }
33803420      }
3381      off++;
3382      s3.wait_rect_x++;
3383      if(s3.wait_rect_x > s3.curr_x + s3.rect_width)
3421      if(s3.current_cmd & 0x0020)
33843422      {
3385         s3.wait_rect_x = s3.curr_x;
3386         s3.wait_rect_y++;
3387         if(s3.wait_rect_y > s3.curr_y + s3.rect_height)
3423         off++;
3424         s3.wait_rect_x++;
3425         if(s3.wait_rect_x > s3.curr_x + s3.rect_width)
33883426         {
3389            s3.state = S3_IDLE;
3390            s3.gpbusy = false;
3427            s3.wait_rect_x = s3.curr_x;
3428            if(s3.current_cmd & 0x0080)
3429            {
3430               s3.wait_rect_y++;
3431               if(s3.wait_rect_y > s3.curr_y + s3.rect_height)
3432               {
3433                  s3.state = S3_IDLE;
3434                  s3.gpbusy = false;
3435               }
3436            }
3437            else
3438            {
3439               s3.wait_rect_y--;
3440               if(s3.wait_rect_y < s3.curr_y - s3.rect_height)
3441               {
3442                  s3.state = S3_IDLE;
3443                  s3.gpbusy = false;
3444               }
3445            }
3446            return;
33913447         }
3392         return;
33933448      }
3449      else
3450      {
3451         off--;
3452         s3.wait_rect_x--;
3453         if(s3.wait_rect_x < s3.curr_x - s3.rect_width)
3454         {
3455            s3.wait_rect_x = s3.curr_x;
3456            if(s3.current_cmd & 0x0080)
3457            {
3458               s3.wait_rect_y++;
3459               if(s3.wait_rect_y > s3.curr_y + s3.rect_height)
3460               {
3461                  s3.state = S3_IDLE;
3462                  s3.gpbusy = false;
3463               }
3464            }
3465            else
3466            {
3467               s3.wait_rect_y--;
3468               if(s3.wait_rect_y < s3.curr_y - s3.rect_height)
3469               {
3470                  s3.state = S3_IDLE;
3471                  s3.gpbusy = false;
3472               }
3473            }
3474            return;
3475         }
3476      }
33943477   }
33953478}
33963479
r17576r17577
34293512WRITE16_HANDLER(s3_backmix_w)
34303513{
34313514   s3.bgmix = data;
3515   logerror("S3: BG Mix write %04x\n",data);
34323516}
34333517
34343518READ16_HANDLER(s3_foremix_r)
r17576r17577
34393523WRITE16_HANDLER(s3_foremix_w)
34403524{
34413525   s3.fgmix = data;
3526   logerror("S3: FG Mix write %04x\n",data);
34423527}
34433528
34443529READ16_HANDLER(s3_pixel_xfer_r)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team