Skip to content

Commit

Permalink
Merge pull request 86Box#4181 from Cacodemon345/chips_69000_black_cur…
Browse files Browse the repository at this point in the history
…sor_64x64_fix

C&T 69000: Fix black cursor on Red Hat Linux 8
  • Loading branch information
OBattler authored Feb 20, 2024
2 parents 49b7c61 + 80adef5 commit 3f65aed
Showing 1 changed file with 43 additions and 24 deletions.
67 changes: 43 additions & 24 deletions src/video/vid_chips_69000.c
Original file line number Diff line number Diff line change
Expand Up @@ -2287,14 +2287,46 @@ chips_69000_vblank_start(svga_t *svga)
chips_69000_interrupt(chips);
}

static void
chips_69000_hwcursor_draw_64x64(svga_t *svga, int displine)
{
chips_69000_t *chips = (chips_69000_t *) svga->priv;
uint64_t dat[2];
int offset = svga->hwcursor_latch.x - svga->hwcursor_latch.xoff;

if (svga->interlace && svga->hwcursor_oddeven)
svga->hwcursor_latch.addr += 16;

dat[1] = bswap64(*(uint64_t *) (&svga->vram[svga->hwcursor_latch.addr]));
dat[0] = bswap64(*(uint64_t *) (&svga->vram[svga->hwcursor_latch.addr + 8]));
svga->hwcursor_latch.addr += 16;

for (uint8_t x = 0; x < 64; x++) {
if (!(dat[1] & (1ULL << 63)))
svga->monitor->target_buffer->line[displine][(offset + svga->x_add) & 2047] = (dat[0] & (1ULL << 63)) ? svga_lookup_lut_ram(svga, chips->cursor_pallook[5]) : svga_lookup_lut_ram(svga, chips->cursor_pallook[4]);
else if (dat[0] & (1ULL << 63))
svga->monitor->target_buffer->line[displine][(offset + svga->x_add) & 2047] ^= 0xffffff;

offset++;
dat[0] <<= 1;
dat[1] <<= 1;
}

if (svga->interlace && !svga->hwcursor_oddeven)
svga->hwcursor_latch.addr += 16;
}

static void
chips_69000_hwcursor_draw(svga_t *svga, int displine)
{
chips_69000_t *chips = (chips_69000_t *) svga->priv;
uint64_t dat[2];
int offset = svga->hwcursor_latch.x - svga->hwcursor_latch.xoff;

if (svga->interlace && (chips->ext_regs[0xa0] & 7) == 0b1) {
if ((chips->ext_regs[0xa0] & 7) == 0b101)
return chips_69000_hwcursor_draw_64x64(svga, displine);

if (svga->interlace) {
dat[1] = bswap64(*(uint64_t *) (&svga->vram[svga->hwcursor_latch.addr]));
dat[0] = bswap64(*(uint64_t *) (&svga->vram[svga->hwcursor_latch.addr + 8]));
svga->hwcursor_latch.addr += 16;
Expand All @@ -2315,10 +2347,7 @@ chips_69000_hwcursor_draw(svga_t *svga, int displine)
return;
}

if (svga->interlace && svga->hwcursor_oddeven)
svga->hwcursor_latch.addr += 16;

if ((svga->hwcursor_on & 1) && (chips->ext_regs[0xa0] & 7) == 0b1) {
if ((svga->hwcursor_on & 1)) {
dat[1] = bswap64(*(uint64_t *) (&svga->vram[svga->hwcursor_latch.addr - 16]));
dat[0] = bswap64(*(uint64_t *) (&svga->vram[(svga->hwcursor_latch.addr - 16) + 8]));
dat[1] <<= 32ULL;
Expand All @@ -2329,27 +2358,17 @@ chips_69000_hwcursor_draw(svga_t *svga, int displine)
dat[0] = bswap64(*(uint64_t *) (&svga->vram[svga->hwcursor_latch.addr + 8]));
svga->hwcursor_latch.addr += 16;
}
switch (chips->ext_regs[0xa0] & 7) {
case 0b1:
case 0b101:
for (uint8_t x = 0; x < (((chips->ext_regs[0xa0] & 7) == 0b1) ? 32 : 64); x++) {
if (!(dat[1] & (1ULL << 63)))
svga->monitor->target_buffer->line[displine & 2047][(offset + svga->x_add) & 2047] = (dat[0] & (1ULL << 63)) ? svga_lookup_lut_ram(svga, chips->cursor_pallook[5]) : svga_lookup_lut_ram(svga, chips->cursor_pallook[4]);
else if (dat[0] & (1ULL << 63))
svga->monitor->target_buffer->line[displine & 2047][(offset + svga->x_add) & 2047] ^= 0xffffff;

offset++;
dat[0] <<= 1;
dat[1] <<= 1;
}
break;

default:
break;
}
for (uint8_t x = 0; x < 32; x++) {
if (!(dat[1] & (1ULL << 63)))
svga->monitor->target_buffer->line[displine & 2047][(offset + svga->x_add) & 2047] = (dat[0] & (1ULL << 63)) ? svga_lookup_lut_ram(svga, chips->cursor_pallook[5]) : svga_lookup_lut_ram(svga, chips->cursor_pallook[4]);
else if (dat[0] & (1ULL << 63))
svga->monitor->target_buffer->line[displine & 2047][(offset + svga->x_add) & 2047] ^= 0xffffff;

if (svga->interlace && !svga->hwcursor_oddeven)
svga->hwcursor_latch.addr += 16;
offset++;
dat[0] <<= 1;
dat[1] <<= 1;
}
}

static float
Expand Down

0 comments on commit 3f65aed

Please sign in to comment.