The emulator crashes. The configuration is the same seen in the screenshot, but also to mention the Stealth 3D 2000, Sound Blaster 16 and 32MB RAM being used.
I haven't tried the latest revision if that changed yet.
More filter WIP code, changed things into lookups
vid_voodoo.c
Code: Select all
uint32_t u;
} rgba_u;
// leilei stuff start
#include <math.h>
int gammer[256]; // gamma correction lookup table
int thefilter[256][256]; // pixel filter, feeding from one or two
int thefilterg[256][256]; // pixel filter, feeding from one or two
void voodoo_generate_gamma(void)
{
int g, h, i;
float color;
int thiscol;
for (g=0;g<256;g++){
color = g / 255;
thiscol = pow(color, 1.7) * 255; // THIS DOES NOT WORK YET
thiscol = g; // so just use the plain color
if (thiscol > 255) thiscol = 255;
if (thiscol < 0) thiscol = 0;
gammer[g] = thiscol;
}
};
#define FILTCAP (0.075 * 255)
#define FILTCAPG (FILTCAP / 2)
int purpleline[256];
// test
int vline[600];
void voodoo_generate_filter(void)
{
int g, h, i;
int difference, diffg;
float color;
int thiscol, thiscolg, lined;
for (g=0;g<256;g++){ // pixel 1
for (h=0;h<256;h++){ // pixel 2
difference = h - g;
diffg = difference;
if (difference > FILTCAP ) difference = FILTCAP;
if (difference < -FILTCAP ) difference = -FILTCAP;
if (diffg > FILTCAPG ) diffg = FILTCAPG;
if (diffg < -FILTCAPG ) diffg = -FILTCAPG;
thiscol = g + (difference/4);
thiscolg = g + (diffg/4);
if (thiscol < 0) thiscol = 0;
if (thiscol > 255) thiscol = 255;
if (thiscolg < 0) thiscolg = 0;
if (thiscolg > 255) thiscolg = 255;
thefilter[g][h] = thiscol;
thefilterg[g][h] = thiscolg;
}
lined = g + 1;
if (lined>24) lined = 24;
purpleline[g] = lined;
}
int vl, a = 1;
for (vl=0;vl<600;vl++)
{
a *= -1;
if (a == 1)
vline[vl] = 1;
else
vline[vl] = 0;
}
};
// leilei stuff end
static rgba_u rgb332[0x100], rgb565[0x10000], argb1555[0x10000], argb4444[0x10000];
Code: Select all
int scrfilter; /* leilei addition */
} voodoo_t;
Code: Select all
void voodoo_callback(void *p)
{
int line = 1;
voodoo_t *voodoo = (voodoo_t *)p;
voodoo->scrfilter = device_get_config_int("dacfilter");
if (voodoo->fbiInit0 & FBIINIT0_VGA_PASS)
{
if (voodoo->line < voodoo->v_disp)
{
uint32_t *p = &((uint32_t *)buffer32->line[voodoo->line])[32];
uint16_t *src = (uint16_t *)&voodoo->fb_mem[voodoo->front_offset + voodoo->line*voodoo->row_width];
int x;
// leilei - dac screen filter, this is a messy hack with bad comment conventions
// a ton of it could be refactored, optimized, and vectorized
// this is just a rough initial implementation by trial and error
if (voodoo->scrfilter){
int j, offset;
unsigned rb[voodoo->h_disp];
unsigned gb[voodoo->h_disp];
unsigned bb[voodoo->h_disp];
for (j=0;j<4;j++) // we must do 4 passes of this
{
for (x = 0; x < voodoo->h_disp; x++)
{
int ren;
int r1,g1,b1;
int r2,g2,b2;
int rd,gd,bd;
if (j==0){
// initial buffer grab
rb[x] = src[x] & 31;
gb[x] = (src[x] >> 5) & 63;
bb[x] = (src[x] >> 11) & 31;
rb[x+1] = src[x+1] & 31;
gb[x+1] = (src[x+1] >> 5) & 63;
bb[x+1] = (src[x+1] >> 11) & 31;
// add lines
if (vline[voodoo->line] == 1){
rb[x] = purpleline[rb[x]];
bb[x] = purpleline[bb[x]];
rb[x+1] = purpleline[rb[x+1]];
bb[x+1] = purpleline[bb[x+1]];
}
}
// handle offset of 4x1, which is supposed to do 3 pixels to the right then one to the left
offset=1;
if (x>0 && j==3) offset=-1;
r1 = thefilter [rb[x]][rb[x+offset]];
g1 = thefilterg [gb[x]][gb[x+offset]];
b1 = thefilter [bb[x]][bb[x+offset]];
if (j==3){ // final buffer write
// TODO: Gamma
p[x] = (gammer[r1] << 3 | gammer[g1] << 10 | gammer[b1] << 19);
}
else // feedback filter linear passes
{
gb[x] = g1;
rb[x] = r1;
bb[x] = b1;
}
}
}
}
else
{
for (x = 0; x < voodoo->h_disp; x++)
{
p[x] = video_16to32[src[x]];
}
}
}
if (voodoo->line == voodoo->v_disp)
Code: Select all
voodoo_make_dither();
// leilei stuff
voodoo_generate_gamma(); // generate gamma lookup table
voodoo_generate_filter(); // generate filter lookup tables
pci_add(voodoo_pci_read, voodoo_pci_write, voodoo);
Code: Select all
.type = CONFIG_BINARY,
.default_int = 1
},
{
.name = "dacfilter",
.description = "Screen Filter",
.type = CONFIG_BINARY,
.default_int = 1
},
{
.type = -1
The line adding code is a bit troublesome and bad because it kept showing green for me, so the line effect isn't correct either