Previous 199869 Revisions Next

r17496 Monday 27th August, 2012 at 07:25:41 UTC by Barry Rodewald
(MESS) svga_s3: Added bitblt function.
[src/emu/video]pc_vga.c

trunk/src/emu/video/pc_vga.c
r17495r17496
191191   S3_IDLE = 0,
192192   S3_DRAWING_RECT,
193193   S3_DRAWING_LINE,
194   S3_DRAWING_BITBLT
194   S3_DRAWING_BITBLT,
195   S3_DRAWING_PATTERN
195196};
196197
197198static struct
r17495r17496
28412842{
28422843   if(s3.enable_8514 != 0)
28432844   {
2844      int x,y;
2845      int x,y,count;
28452846      int dir_x;
2846      UINT32 offset;
2847      UINT32 offset,src;
2848      UINT8* buffer;  // for bitblt operations
2849
28472850      s3.current_cmd = data;
28482851      switch(data & 0xe000)
28492852      {
r17495r17496
28732876         {
28742877            for(x=0;x<=s3.rect_width;x+=dir_x)
28752878            {
2876               vga.memory[(offset+x) % vga.svga_intf.vram_size] = s3.fgcolour & 0x000000ff;  // TODO: handle 16-bit or 32-bit transfers
2879               vga.memory[(offset+x) % vga.svga_intf.vram_size] = s3.fgcolour & 0x000000ff;
28772880               vga.memory[(offset+x+1) % vga.svga_intf.vram_size] = (s3.fgcolour & 0x0000ff00) >> 8;
28782881            }
28792882            offset += VGA_LINE_LENGTH;
28802883         }
2881         logerror("S3: Command (%04x) - Rectangle Fill %i,%i Width: %i Height: %i Colour: %08x\n",s3.current_cmd,s3.curr_x,s3.curr_y,s3.rect_width,s3.rect_height,s3.fgcolour);
2884         s3.gpbusy = false;
2885         logerror("S3: Command (%04x) - Rectangle Fill %i,%i Width: %i Height: %i Colour: %08x\n",s3.current_cmd,s3.curr_x,
2886               s3.curr_y,s3.rect_width,s3.rect_height,s3.fgcolour);
28822887         break;
28832888      case 0xc000:  // BitBLT
2889         offset = VGA_START_ADDRESS;
2890         offset += (VGA_LINE_LENGTH * s3.dest_y);
2891         offset += s3.dest_x;
2892         src = VGA_START_ADDRESS;
2893         src += (VGA_LINE_LENGTH * s3.curr_y);
2894         src += s3.curr_x;
2895         buffer = (UINT8*)malloc((s3.rect_height+1)*(s3.rect_width+1));
2896         count = 0;
2897         // copy to temporary buffer
2898         for(y=0;y<=s3.rect_height;y++)
2899         {
2900            for(x=0;x<=s3.rect_width;x++)
2901            {
2902               if(data & 0x0020)
2903                  buffer[count++] = vga.memory[(src+x) % vga.svga_intf.vram_size];
2904               else
2905                  buffer[count++] = vga.memory[(src-x) % vga.svga_intf.vram_size];
2906            }
2907            if(data & 0x0080)
2908               src += VGA_LINE_LENGTH;
2909            else
2910               src -= VGA_LINE_LENGTH;
2911         }
2912         // write from buffer to screen
2913         count = 0;
2914         for(y=0;y<=s3.rect_height;y++)
2915         {
2916            for(x=0;x<=s3.rect_width;x++)
2917            {
2918               if(data & 0x0020)
2919                  vga.memory[(offset+x) % vga.svga_intf.vram_size] = buffer[count++];
2920               else
2921                  vga.memory[(offset-x) % vga.svga_intf.vram_size] = buffer[count++];
2922            }
2923            if(data & 0x0080)
2924               offset += VGA_LINE_LENGTH;
2925            else
2926               offset -= VGA_LINE_LENGTH;
2927         }
2928         free(buffer);
28842929         s3.gpbusy = false;
2885         logerror("S3: Command (%04x) - BitBLT\n",s3.current_cmd);
2930         logerror("S3: Command (%04x) - BitBLT from %i,%i to %i,%i  Width: %i  Height: %i\n",s3.current_cmd,
2931               s3.curr_x,s3.curr_y,s3.dest_x,s3.dest_y,s3.rect_width,s3.rect_height);
28862932         break;
28872933      case 0xe000:  // Pattern Fill
28882934         s3.gpbusy = false;
r17495r17496
29743020WRITE16_HANDLER(s3_currentx_w)
29753021{
29763022   s3.curr_x = data & 0x0fff;
3023   logerror("S3: Current X set to %04x\n",data);
29773024}
29783025
29793026READ16_HANDLER(s3_currenty_r)
r17495r17496
29843031WRITE16_HANDLER(s3_currenty_w)
29853032{
29863033   s3.curr_y = data & 0x0fff;
3034   logerror("S3: Current Y set to %04x\n",data);
29873035}
29883036
29893037READ16_HANDLER(s3_fgcolour_r)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team