Previous 199869 Revisions Next

r17650 Wednesday 5th September, 2012 at 07:54:18 UTC by Barry Rodewald
(MESS) svga_s3: Added basic support for Bresenham lines.
[src/emu/video]pc_vga.c

trunk/src/emu/video/pc_vga.c
r17649r17650
213213   INT16 prev_y;
214214   UINT16 src_x;
215215   UINT16 src_y;
216   UINT16 line_axial_step;
217   UINT16 line_diagonal_step;
218   UINT16 line_errorterm;
216   INT16 line_axial_step;
217   INT16 line_diagonal_step;
218   INT16 line_errorterm;
219219   UINT16 rect_width;
220220   UINT16 rect_height;
221221   UINT32 fgcolour;
r17649r17650
25192519   {
25202520      switch(index)
25212521      {
2522//         case 0x2e:
2523//            res = 0x11;  // Trio64
2524//            break;
2525//         case 0x2f:
2526//            res = 0x00;
2527//            break;
25222528         case 0x30: // CR30 Chip ID/REV register
2523            res = 0xc0; // TODO: hardcoded to Vision 86c864
2529            res = 0xc0; // BIOS is from a card with the 764 chipset (Trio64)
25242530            break;
25252531         case 0x31:
25262532            res = s3.memory_config;
r17649r17650
29782984
29792985WRITE16_HANDLER(s3_line_error_w)
29802986{
2981   s3.line_errorterm = data & 0x3fff;
2987   s3.line_errorterm = data;
29822988   logerror("S3: Line Parameter/Error Term write %04x\n",data);
29832989}
29842990
r17649r17650
31223128      case 0x2000:  // Line
31233129         s3.state = S3_IDLE;
31243130         s3.gpbusy = false;
3125         logerror("S3: Command (%04x) - Line\n",s3.current_cmd);
3131         if(data & 0x0008)
3132         {
3133            // TODO
3134            logerror("S3: Command (%04x) - Line (Vector) - %i,%i \n",s3.current_cmd,s3.curr_x,s3.curr_y);
3135         }
3136         else
3137         {
3138            // Not perfect, but will do for now.
3139            INT16 dx = s3.rect_width;
3140            INT16 dy = s3.line_axial_step >> 1;
3141            INT16 err = s3.line_errorterm;
3142            int sx = (data & 0x0020) ? 1 : -1;
3143            int sy = (data & 0x0080) ? 1 : -1;
3144            int count = 0;
3145            INT16 temp;
3146
3147            logerror("S3: Command (%04x) - Line (Bresenham) - %i,%i  Axial %i, Diagonal %i, Error %i, Major Axis %i, Minor Axis %i\n",s3.current_cmd,
3148               s3.curr_x,s3.curr_y,s3.line_axial_step,s3.line_diagonal_step,s3.line_errorterm,s3.rect_width,s3.rect_height);
3149
3150            if((data & 0x0040))
3151            {
3152               temp = dx; dx = dy; dy = temp;
3153            }
3154            for(;;)
3155            {
3156               s3_write(s3.curr_x + (s3.curr_y * VGA_LINE_LENGTH),s3.curr_x + (s3.curr_y * VGA_LINE_LENGTH));
3157               if (count > s3.rect_width) break;
3158               count++;
3159               if((err*2) > -dy)
3160               {
3161                  err -= dy;
3162                  s3.curr_x += sx;
3163               }
3164               if((err*2) < dx)
3165               {
3166                  err += dx;
3167                  s3.curr_y += sy;
3168               }
3169            }
3170         }
31263171         break;
31273172      case 0x4000:  // Rectangle Fill
31283173         if(data & 0x0100)  // WAIT (for read/write of PIXEL TRANSFER (E2E8))
r17649r17650
31343179                  s3.curr_y,s3.rect_width,s3.rect_height,s3.fgcolour);
31353180            break;
31363181         }
3182         logerror("S3: Command (%04x) - Rectangle Fill %i,%i Width: %i Height: %i Colour: %08x\n",s3.current_cmd,s3.curr_x,
3183               s3.curr_y,s3.rect_width,s3.rect_height,s3.fgcolour);
31373184         offset = 0;
31383185         offset += (VGA_LINE_LENGTH * s3.curr_y);
31393186         offset += s3.curr_x;
r17649r17650
31793226         }
31803227         s3.state = S3_IDLE;
31813228         s3.gpbusy = false;
3182         logerror("S3: Command (%04x) - Rectangle Fill %i,%i Width: %i Height: %i Colour: %08x\n",s3.current_cmd,s3.curr_x,
3183               s3.curr_y,s3.rect_width,s3.rect_height,s3.fgcolour);
31843229         break;
31853230      case 0xc000:  // BitBLT
3231         logerror("S3: Command (%04x) - BitBLT from %i,%i to %i,%i  Width: %i  Height: %i\n",s3.current_cmd,
3232               s3.curr_x,s3.curr_y,s3.dest_x,s3.dest_y,s3.rect_width,s3.rect_height);
31863233         offset = 0;
31873234         offset += (VGA_LINE_LENGTH * s3.dest_y);
31883235         offset += s3.dest_x;
r17649r17650
32373284         }
32383285         s3.state = S3_IDLE;
32393286         s3.gpbusy = false;
3240         logerror("S3: Command (%04x) - BitBLT from %i,%i to %i,%i  Width: %i  Height: %i\n",s3.current_cmd,
3241               s3.curr_x,s3.curr_y,s3.dest_x,s3.dest_y,s3.rect_width,s3.rect_height);
32423287         break;
32433288      case 0xe000:  // Pattern Fill
3289         logerror("S3: Command (%04x) - Pattern Fill - source %i,%i  dest %i,%i  Width: %i Height: %i\n",s3.current_cmd,
3290               s3.curr_x,s3.curr_y,s3.dest_x,s3.dest_y,s3.rect_width,s3.rect_height);
32443291         offset = 0;
32453292         offset += (VGA_LINE_LENGTH * s3.dest_y);
32463293         offset += s3.dest_x;
r17649r17650
33063353         }
33073354         s3.state = S3_IDLE;
33083355         s3.gpbusy = false;
3309         logerror("S3: Command (%04x) - Pattern Fill - source %i,%i  dest %i,%i  Width: %i Height: %i\n",s3.current_cmd,
3310               s3.curr_x,s3.curr_y,s3.dest_x,s3.dest_y,s3.rect_width,s3.rect_height);
33113356         break;
33123357      default:
33133358         s3.state = S3_IDLE;
r17649r17650
33383383
33393384WRITE16_HANDLER( s3_8ae8_w )
33403385{
3341   s3.line_axial_step = data & 0x3fff;
3386   s3.line_axial_step = data;
33423387   s3.dest_y = data;
33433388   logerror("S3: Line Axial Step / Destination Y write %04x\n",data);
33443389}
r17649r17650
33633408
33643409WRITE16_HANDLER( s3_8ee8_w )
33653410{
3366   s3.line_diagonal_step = data & 0x3fff;
3411   s3.line_diagonal_step = data;
33673412   s3.dest_x = data;
33683413   logerror("S3: Line Diagonal Step / Destination X write %04x\n",data);
33693414}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team