PCem

changeset 161:b6874c4f3917

ViRGE hardware cursor now supports X11 format cursors, and uses colour registers.
author TomW
date Sat Sep 20 18:00:54 2014 +0100
parents 5bddbc972079
children a0a99c64d528
files src/vid_s3_virge.c
diffstat 1 files changed, 48 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/src/vid_s3_virge.c	Sat Sep 20 17:24:23 2014 +0100
     1.2 +++ b/src/vid_s3_virge.c	Sat Sep 20 18:00:54 2014 +0100
     1.3 @@ -105,6 +105,9 @@
     1.4          event_t *wake_render_thread;
     1.5          event_t *wake_main_thread;
     1.6          event_t *not_full_event;
     1.7 +        
     1.8 +        uint32_t hwcursor_col[2];
     1.9 +        int hwcursor_col_pos;
    1.10                          
    1.11          struct
    1.12          {
    1.13 @@ -339,6 +342,19 @@
    1.14                          svga->hwcursor.yoff = svga->crtc[0x4f] & 63;
    1.15                          svga->hwcursor.addr = ((((svga->crtc[0x4c] << 8) | svga->crtc[0x4d]) & 0xfff) * 1024) + (svga->hwcursor.yoff * 16);
    1.16                          break;
    1.17 +                        
    1.18 +                        case 0x4a:
    1.19 +                        virge->hwcursor_col[1] = (virge->hwcursor_col[1] & ~(0xff << (virge->hwcursor_col_pos * 8))) |
    1.20 +                                                 (val << (virge->hwcursor_col_pos * 8));
    1.21 +                        virge->hwcursor_col_pos++;
    1.22 +                        virge->hwcursor_col_pos &= 3;
    1.23 +                        break;
    1.24 +                        case 0x4b:
    1.25 +                        virge->hwcursor_col[0] = (virge->hwcursor_col[0] & ~(0xff << (virge->hwcursor_col_pos * 8))) |
    1.26 +                                                 (val << (virge->hwcursor_col_pos * 8));
    1.27 +                        virge->hwcursor_col_pos++;
    1.28 +                        virge->hwcursor_col_pos &= 3;
    1.29 +                        break;
    1.30  
    1.31                          case 0x53:
    1.32                          case 0x58: case 0x59: case 0x5a:
    1.33 @@ -416,6 +432,7 @@
    1.34                          case 0x31: ret = (svga->crtc[0x31] & 0xcf) | ((virge->ma_ext & 3) << 4); break;
    1.35                          case 0x35: ret = (svga->crtc[0x35] & 0xf0) | (virge->bank & 0xf); break;
    1.36                          case 0x36: ret = (svga->crtc[0x36] & 0xfc) | 2; break; /*PCI bus*/
    1.37 +                        case 0x45: virge->hwcursor_col_pos = 0; ret = svga->crtc[0x45]; break;
    1.38                          case 0x51: ret = (svga->crtc[0x51] & 0xf0) | ((virge->bank >> 2) & 0xc) | ((virge->ma_ext >> 2) & 3); break;
    1.39                          case 0x69: ret = virge->ma_ext; break;
    1.40                          case 0x6a: ret = virge->bank; break;
    1.41 @@ -2729,6 +2746,7 @@
    1.42  
    1.43  static void s3_virge_hwcursor_draw(svga_t *svga, int displine)
    1.44  {
    1.45 +        virge_t *virge = (virge_t *)svga->p;
    1.46          int x;
    1.47          uint16_t dat[2];
    1.48          int xx;
    1.49 @@ -2739,20 +2757,40 @@
    1.50          {
    1.51                  dat[0] = (svga->vram[svga->hwcursor_latch.addr]     << 8) | svga->vram[svga->hwcursor_latch.addr + 1];
    1.52                  dat[1] = (svga->vram[svga->hwcursor_latch.addr + 2] << 8) | svga->vram[svga->hwcursor_latch.addr + 3];
    1.53 -                for (xx = 0; xx < 16; xx++)
    1.54 +                if (svga->crtc[0x55] & 0x10)
    1.55                  {
    1.56 -                        if (offset >= svga->hwcursor_latch.x)
    1.57 +                        /*X11*/
    1.58 +                        for (xx = 0; xx < 16; xx++)
    1.59                          {
    1.60 -                                if (!(dat[0] & 0x8000))
    1.61 -                                   ((uint32_t *)buffer32->line[displine])[offset + 32]  = (dat[1] & 0x8000) ? 0xffffff : 0;
    1.62 -                                else if (dat[1] & 0x8000)
    1.63 -                                   ((uint32_t *)buffer32->line[displine])[offset + 32] ^= 0xffffff;
    1.64 +                                if (offset >= svga->hwcursor_latch.x)
    1.65 +                                {
    1.66 +                                        if (dat[0] & 0x8000)
    1.67 +                                                ((uint32_t *)buffer32->line[displine])[offset + 32]  = virge->hwcursor_col[dat[1] >> 15];
    1.68 +                                }
    1.69 +                           
    1.70 +                                offset++;
    1.71 +                                dat[0] <<= 1;
    1.72 +                                dat[1] <<= 1;
    1.73 +                        }
    1.74 +                }
    1.75 +                else
    1.76 +                {
    1.77 +                        /*Windows*/
    1.78 +                        for (xx = 0; xx < 16; xx++)
    1.79 +                        {
    1.80 +                                if (offset >= svga->hwcursor_latch.x)
    1.81 +                                {
    1.82 +                                        if (!(dat[0] & 0x8000))
    1.83 +                                           ((uint32_t *)buffer32->line[displine])[offset + 32]  = virge->hwcursor_col[dat[1] >> 15];
    1.84 +                                        else if (dat[1] & 0x8000)
    1.85 +                                           ((uint32_t *)buffer32->line[displine])[offset + 32] ^= 0xffffff;
    1.86  //                                pclog("Plot %i, %i (%i %i) %04X %04X\n", offset, displine, x+xx, svga->hwcursor_on, dat[0], dat[1]);
    1.87 +                                }
    1.88 +                           
    1.89 +                                offset++;
    1.90 +                                dat[0] <<= 1;
    1.91 +                                dat[1] <<= 1;
    1.92                          }
    1.93 -                           
    1.94 -                        offset++;
    1.95 -                        dat[0] <<= 1;
    1.96 -                        dat[1] <<= 1;
    1.97                  }
    1.98                  svga->hwcursor_latch.addr += 4;
    1.99          }