Updated gfxutil from WinUAE (but commented out the unused code)
This commit is contained in:
parent
9a925a3545
commit
6c1175b1b8
1 changed files with 132 additions and 41 deletions
173
src/gfxutil.cpp
173
src/gfxutil.cpp
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* UAE - The Un*x Amiga Emulator
|
||||
*
|
||||
* Common code needed by all the various graphics systems.
|
||||
*
|
||||
* (c) 1996 Bernd Schmidt, Ed Hanway, Samuel Devulder
|
||||
*/
|
||||
* UAE - The Un*x Amiga Emulator
|
||||
*
|
||||
* Common code needed by all the various graphics systems.
|
||||
*
|
||||
* (c) 1996 Bernd Schmidt, Ed Hanway, Samuel Devulder
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -13,10 +13,35 @@
|
|||
#include "custom.h"
|
||||
#include "rtgmodes.h"
|
||||
#include "xwin.h"
|
||||
//#include "gfxfilter.h"
|
||||
|
||||
#define RED 0
|
||||
#define GRN 1
|
||||
#define BLU 2
|
||||
#include <math.h>
|
||||
|
||||
float getvsyncrate(float hz, int *mult)
|
||||
{
|
||||
struct amigadisplay *ad = &adisplays;
|
||||
struct apmode *ap = ad->picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0];
|
||||
|
||||
if (hz < 0)
|
||||
return 0;
|
||||
if (hz > 85) {
|
||||
*mult = -1;
|
||||
return hz / 2;
|
||||
}
|
||||
if (hz < 35 && hz > 0) {
|
||||
if (ap->gfx_interlaced)
|
||||
*mult = 0;
|
||||
else
|
||||
*mult = 1;
|
||||
return hz * 2;
|
||||
}
|
||||
*mult = 0;
|
||||
return hz;
|
||||
}
|
||||
|
||||
#define RED 0
|
||||
#define GRN 1
|
||||
#define BLU 2
|
||||
|
||||
unsigned int doMask (int p, int bits, int shift)
|
||||
{
|
||||
|
@ -32,34 +57,32 @@ unsigned int doMask (int p, int bits, int shift)
|
|||
return val;
|
||||
}
|
||||
|
||||
int bits_in_mask(unsigned long mask)
|
||||
int bits_in_mask (unsigned long mask)
|
||||
{
|
||||
int n = 0;
|
||||
while (mask)
|
||||
{
|
||||
while (mask) {
|
||||
n += mask & 1;
|
||||
mask >>= 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int mask_shift(unsigned long mask)
|
||||
int mask_shift (unsigned long mask)
|
||||
{
|
||||
int n = 0;
|
||||
if (!mask)
|
||||
return 0;
|
||||
while (!(mask & 1))
|
||||
{
|
||||
while (!(mask & 1)) {
|
||||
n++;
|
||||
mask >>= 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
unsigned int doMask256(int p, int bits, int shift)
|
||||
unsigned int doMask256 (int p, int bits, int shift)
|
||||
{
|
||||
/* p is a value from 0 to 255 (Amiga color value)
|
||||
* shift to align msb with mask, and apply mask */
|
||||
* shift to align msb with mask, and apply mask */
|
||||
|
||||
unsigned long val = p * 0x01010101UL;
|
||||
if (bits == 0)
|
||||
|
@ -70,7 +93,7 @@ unsigned int doMask256(int p, int bits, int shift)
|
|||
return val;
|
||||
}
|
||||
|
||||
static unsigned int doColor(int i, int bits, int shift)
|
||||
static unsigned int doColor (int i, int bits, int shift)
|
||||
{
|
||||
int shift2;
|
||||
|
||||
|
@ -81,7 +104,7 @@ static unsigned int doColor(int i, int bits, int shift)
|
|||
return (i >> shift2) << shift;
|
||||
}
|
||||
|
||||
static unsigned int doAlpha(int alpha, int bits, int shift)
|
||||
static unsigned int doAlpha (int alpha, int bits, int shift)
|
||||
{
|
||||
return (alpha & ((1 << bits) - 1)) << shift;
|
||||
}
|
||||
|
@ -92,7 +115,7 @@ extern uae_s32 tcbrgb[65536];
|
|||
extern uae_s32 tcrrgb[65536];
|
||||
extern uae_u32 redc[3 * 256], grec[3 * 256], bluc[3 * 256];
|
||||
|
||||
static uae_u32 lowbits(int v, int shift, int lsize)
|
||||
static uae_u32 lowbits (int v, int shift, int lsize)
|
||||
{
|
||||
v >>= shift;
|
||||
v &= (1 << lsize) - 1;
|
||||
|
@ -194,16 +217,16 @@ void alloc_colors_picasso (int rw, int gw, int bw, int rs, int gs, int bs, int r
|
|||
#endif
|
||||
}
|
||||
|
||||
void alloc_colors_rgb(int rw, int gw, int bw, int rs, int gs, int bs, int aw, int as, int alpha, int byte_swap,
|
||||
uae_u32* rc, uae_u32* gc, uae_u32* bc)
|
||||
void alloc_colors_rgb (int rw, int gw, int bw, int rs, int gs, int bs, int aw, int as, int alpha, int byte_swap,
|
||||
uae_u32 *rc, uae_u32 *gc, uae_u32 *bc)
|
||||
{
|
||||
int bpp = rw + gw + bw + aw;
|
||||
int i;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
rc[i] = doColor(i, rw, rs);
|
||||
gc[i] = doColor(i, gw, gs);
|
||||
bc[i] = doColor(i, bw, bs);
|
||||
rc[i] = doColor(i, rw, rs) | doAlpha (alpha, aw, as);
|
||||
gc[i] = doColor(i, gw, gs) | doAlpha (alpha, aw, as);
|
||||
bc[i] = doColor(i, bw, bs) | doAlpha (alpha, aw, as);
|
||||
if (byte_swap)
|
||||
{
|
||||
if (bpp <= 16)
|
||||
|
@ -219,8 +242,7 @@ void alloc_colors_rgb(int rw, int gw, int bw, int rs, int gs, int bs, int aw, in
|
|||
bc[i] = bswap_32(bc[i]);
|
||||
}
|
||||
}
|
||||
if (bpp <= 16)
|
||||
{
|
||||
if (bpp <= 16) {
|
||||
/* Fill upper 16 bits of each colour value with
|
||||
* a copy of the colour. */
|
||||
rc[i] = rc[i] * 0x00010001;
|
||||
|
@ -232,38 +254,107 @@ void alloc_colors_rgb(int rw, int gw, int bw, int rs, int gs, int bs, int aw, in
|
|||
|
||||
void alloc_colors64k(int rw, int gw, int bw, int rs, int gs, int bs, int aw, int as, int alpha, int byte_swap, bool yuv)
|
||||
{
|
||||
int bpp = rw + gw + bw;
|
||||
int bpp = rw + gw + bw + aw;
|
||||
int i, j;
|
||||
|
||||
j = 256;
|
||||
for (i = 0; i < 4096; i++)
|
||||
{
|
||||
for (i = 0; i < 4096; i++) {
|
||||
int r = ((i >> 8) << 4) | (i >> 8);
|
||||
int g = (((i >> 4) & 0xf) << 4) | ((i >> 4) & 0x0f);
|
||||
int b = ((i & 0xf) << 4) | (i & 0x0f);
|
||||
//r = gamma_value[r + j][0];
|
||||
//g = gamma_value[g + j][1];
|
||||
//b = gamma_value[b + j][2];
|
||||
xcolors[i] = doMask(r, rw, rs) | doMask(g, gw, gs) | doMask(b, bw, bs);
|
||||
if (byte_swap)
|
||||
{
|
||||
if (bpp <= 16)
|
||||
{
|
||||
xcolors[i] = doMask(r, rw, rs) | doMask(g, gw, gs) | doMask(b, bw, bs) | doAlpha(alpha, aw, as);
|
||||
if (byte_swap) {
|
||||
if (bpp <= 16) {
|
||||
xcolors[i] = bswap_16(xcolors[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
xcolors[i] = bswap_32(xcolors[i]);
|
||||
}
|
||||
}
|
||||
if (bpp <= 16)
|
||||
{
|
||||
if (bpp <= 16) {
|
||||
/* Fill upper 16 bits of each colour value
|
||||
* with a copy of the colour. */
|
||||
xcolors[i] |= xcolors[i] * 0x00010001;
|
||||
}
|
||||
}
|
||||
#if defined(AGA)
|
||||
alloc_colors_rgb(rw, gw, bw, rs, gs, bs, aw, as, alpha, byte_swap, xredcolors, xgreencolors, xbluecolors);
|
||||
alloc_colors_rgb (rw, gw, bw, rs, gs, bs, aw, as, alpha, byte_swap, xredcolors, xgreencolors, xbluecolors);
|
||||
/* copy original color table */
|
||||
//for (i = 0; i < 256; i++) {
|
||||
// redc[0 * 256 + i] = xredcolors[0];
|
||||
// grec[0 * 256 + i] = xgreencolors[0];
|
||||
// bluc[0 * 256 + i] = xbluecolors[0];
|
||||
// redc[1 * 256 + i] = xredcolors[i];
|
||||
// grec[1 * 256 + i] = xgreencolors[i];
|
||||
// bluc[1 * 256 + i] = xbluecolors[i];
|
||||
// redc[2 * 256 + i] = xredcolors[255];
|
||||
// grec[2 * 256 + i] = xgreencolors[255];
|
||||
// bluc[2 * 256 + i] = xbluecolors[255];
|
||||
//}
|
||||
#ifdef GFXFILTER
|
||||
if (yuv) {
|
||||
/* create internal 5:6:5 color tables */
|
||||
for (i = 0; i < 256; i++) {
|
||||
j = i + 256;
|
||||
xredcolors[i] = doColor (gamma[j][0], 5, 11);
|
||||
xgreencolors[i] = doColor (gamma[j][1], 6, 5);
|
||||
xbluecolors[i] = doColor (gamma[j][2], 5, 0);
|
||||
if (bpp <= 16) {
|
||||
/* Fill upper 16 bits of each colour value with
|
||||
* a copy of the colour. */
|
||||
xredcolors [i] = xredcolors [i] * 0x00010001;
|
||||
xgreencolors[i] = xgreencolors[i] * 0x00010001;
|
||||
xbluecolors [i] = xbluecolors [i] * 0x00010001;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 4096; i++) {
|
||||
int r = ((i >> 8) << 4) | (i >> 8);
|
||||
int g = (((i >> 4) & 0xf) << 4) | ((i >> 4) & 0x0f);
|
||||
int b = ((i & 0xf) << 4) | (i & 0x0f);
|
||||
r = gamma[r + 256][0];
|
||||
g = gamma[g + 256][1];
|
||||
b = gamma[b + 256][2];
|
||||
xcolors[i] = doMask(r, 5, 11) | doMask(g, 6, 5) | doMask(b, 5, 0);
|
||||
if (byte_swap) {
|
||||
if (bpp <= 16)
|
||||
xcolors[i] = bswap_16 (xcolors[i]);
|
||||
else
|
||||
xcolors[i] = bswap_32 (xcolors[i]);
|
||||
}
|
||||
if (bpp <= 16) {
|
||||
/* Fill upper 16 bits of each colour value
|
||||
* with a copy of the colour. */
|
||||
xcolors[i] |= xcolors[i] * 0x00010001;
|
||||
}
|
||||
}
|
||||
|
||||
/* create RGB 5:6:5 -> YUV tables */
|
||||
for (i = 0; i < 65536; i++) {
|
||||
uae_u32 r, g, b;
|
||||
r = (((i >> 11) & 31) << 3) | lowbits (i, 11, 3);
|
||||
r = gamma[r + 256][0];
|
||||
g = (((i >> 5) & 63) << 2) | lowbits (i, 5, 2);
|
||||
g = gamma[g + 256][1];
|
||||
b = (((i >> 0) & 31) << 3) | lowbits (i, 0, 3);
|
||||
b = gamma[b + 256][2];
|
||||
tyhrgb[i] = get_yh(monid, r, g, b) * 256 * 256;
|
||||
tylrgb[i] = get_yl(monid, r, g, b) * 256 * 256;
|
||||
tcbrgb[i] = ((uae_s8)get_cb(monid, r, g, b)) * 256;
|
||||
tcrrgb[i] = ((uae_s8)get_cr(monid, r, g, b)) * 256;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
//xredcolor_b = rw;
|
||||
//xgreencolor_b = gw;
|
||||
//xbluecolor_b = bw;
|
||||
//xredcolor_s = rs;
|
||||
//xgreencolor_s = gs;
|
||||
//xbluecolor_s = bs;
|
||||
//xredcolor_m = ((1 << rw) - 1) << xredcolor_s;
|
||||
//xgreencolor_m = ((1 << gw) - 1) << xgreencolor_s;
|
||||
//xbluecolor_m = ((1 << bw) - 1) << xbluecolor_s;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue