Skip to content

Commit

Permalink
vid_voodoo_banshee: Implement gamma correction for 16bpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 committed Dec 30, 2023
1 parent de2f347 commit ddb43a7
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/video/vid_voodoo_banshee.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ enum {
#define VIDPROCCFG_INTERLACE (1 << 3)
#define VIDPROCCFG_HALF_MODE (1 << 4)
#define VIDPROCCFG_OVERLAY_ENABLE (1 << 8)
#define VIDPROCCFG_DESKTOP_CLUT_BYPASS (1 << 10)
#define VIDPROCCFG_OVERLAY_CLUT_BYPASS (1 << 11)
#define VIDPROCCFG_DESKTOP_CLUT_SEL (1 << 12)
#define VIDPROCCFG_OVERLAY_CLUT_SEL (1 << 13)
#define VIDPROCCFG_H_SCALE_ENABLE (1 << 14)
#define VIDPROCCFG_V_SCALE_ENABLE (1 << 15)
Expand Down Expand Up @@ -466,6 +468,32 @@ banshee_updatemapping(banshee_t *banshee)
mem_mapping_set_addr(&banshee->reg_mapping_high, banshee->memBaseAddr0 + 0xc00000, 20 << 20);
}

uint32_t
banshee_conv_16to32(svga_t* svga, uint16_t color, uint8_t bpp)
{
banshee_t *banshee = (banshee_t *) svga->priv;
uint32_t ret = 0x00000000;
uint16_t src_b = (color & 0x1f) << 3;
uint16_t src_g = (color & 0x7e0) >> 3;
uint16_t src_r = (color & 0xf800) >> 8;

if (banshee->vidProcCfg & VIDPROCCFG_DESKTOP_CLUT_SEL) {
src_b += 256;
src_g += 256;
src_r += 256;
}

if (svga->lut_map) {
uint8_t b = getcolr(svga->pallook[src_b]);
uint8_t g = getcolg(svga->pallook[src_g]);
uint8_t r = getcolb(svga->pallook[src_r]);
ret = (video_16to32[color] & 0xFF000000) | makecol(r, g, b);
} else
ret = video_16to32[color];

return ret;
}

static void
banshee_render_16bpp_tiled(svga_t *svga)
{
Expand All @@ -489,7 +517,7 @@ banshee_render_16bpp_tiled(svga_t *svga)
const uint16_t *vram_p = (uint16_t *) &svga->vram[addr & svga->vram_display_mask];

for (uint8_t xx = 0; xx < 64; xx++)
*p++ = video_16to32[*vram_p++];
*p++ = banshee_conv_16to32(svga, *vram_p++, 16);

drawn = 1;
} else
Expand Down Expand Up @@ -806,6 +834,7 @@ banshee_ext_outl(uint16_t addr, uint32_t val, void *priv)
banshee->overlay_pix_fmt = (val & VIDPROCCFG_OVERLAY_PIX_FORMAT_MASK) >> VIDPROCCFG_OVERLAY_PIX_FORMAT_SHIFT;
svga->hwcursor.ena = val & VIDPROCCFG_HWCURSOR_ENA;
svga->fullchange = changeframecount;
svga->lut_map = !(val & VIDPROCCFG_DESKTOP_CLUT_BYPASS) && (svga->bpp < 24);
svga_recalctimings(svga);
break;

Expand Down Expand Up @@ -3190,6 +3219,8 @@ banshee_init_common(const device_t *info, char *fn, int has_sgram, int type, int
banshee->i2c_ddc = i2c_gpio_init("ddc_voodoo_banshee");
banshee->ddc = ddc_init(i2c_gpio_get_bus(banshee->i2c_ddc));

banshee->svga.conv_16to32 = banshee_conv_16to32;

switch (type) {
case TYPE_BANSHEE:
if (has_sgram) {
Expand Down

0 comments on commit ddb43a7

Please sign in to comment.