kode54 - LCD merged into Gameboy colours setting.
bgk - gfx patch added
This commit is contained in:
parent
e5794be79b
commit
cf20d2c133
|
@ -24,6 +24,9 @@ extern "C" {
|
|||
#include "common/memgzio.h"
|
||||
}
|
||||
|
||||
#include "gba/gbafilter.h"
|
||||
#include "gb/gbGlobals.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#define _stricmp strcasecmp
|
||||
#endif // ! _MSC_VER
|
||||
|
@ -630,7 +633,7 @@ void utilGBAFindSave(const u8 *data, const int size)
|
|||
flashSetSize(flashSize);
|
||||
}
|
||||
|
||||
void utilUpdateSystemColorMaps()
|
||||
void utilUpdateSystemColorMaps(bool lcd)
|
||||
{
|
||||
switch(systemColorDepth) {
|
||||
case 16:
|
||||
|
@ -640,6 +643,7 @@ void utilUpdateSystemColorMaps()
|
|||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd) gbafilter_pal(systemColorMap16, 0x10000);
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
|
@ -650,6 +654,7 @@ void utilUpdateSystemColorMaps()
|
|||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd) gbafilter_pal32(systemColorMap32, 0x10000);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ int utilGzClose(gzFile file);
|
|||
z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence);
|
||||
long utilGzMemTell(gzFile file);
|
||||
void utilGBAFindSave(const u8 *, const int);
|
||||
void utilUpdateSystemColorMaps();
|
||||
void utilUpdateSystemColorMaps(bool lcd = false);
|
||||
bool utilFileExists( const char *filename );
|
||||
|
||||
#endif // UTIL_H
|
||||
|
|
341
src/gba/GBAGfx.h
341
src/gba/GBAGfx.h
|
@ -5,10 +5,10 @@
|
|||
#include "Globals.h"
|
||||
|
||||
#include "../common/Port.h"
|
||||
#include <string.h>
|
||||
|
||||
//#define SPRITE_DEBUG
|
||||
|
||||
static void gfxDrawTextScreen(u16, u16, u16, u32 *);
|
||||
static void gfxDrawRotScreen(u16,
|
||||
u16, u16,
|
||||
u16, u16,
|
||||
|
@ -98,145 +98,246 @@ static inline void gfxClearArray(u32 *array)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
|
||||
u32 *line)
|
||||
union u8h
|
||||
{
|
||||
u16 *palette = (u16 *)paletteRAM;
|
||||
u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000];
|
||||
u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) * 0x800];
|
||||
u32 prio = ((control & 3)<<25) + 0x1000000;
|
||||
int sizeX = 256;
|
||||
int sizeY = 256;
|
||||
switch((control >> 14) & 3) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
sizeX = 512;
|
||||
break;
|
||||
case 2:
|
||||
sizeY = 512;
|
||||
break;
|
||||
case 3:
|
||||
sizeX = 512;
|
||||
sizeY = 512;
|
||||
break;
|
||||
}
|
||||
struct
|
||||
{
|
||||
/* 0*/ unsigned lo:4;
|
||||
/* 4*/ unsigned hi:4;
|
||||
} __attribute__ ((packed));
|
||||
u8 val;
|
||||
};
|
||||
|
||||
int maskX = sizeX-1;
|
||||
int maskY = sizeY-1;
|
||||
union TileEntry
|
||||
{
|
||||
struct
|
||||
{
|
||||
/* 0*/ unsigned tileNum:10;
|
||||
/*12*/ unsigned hFlip:1;
|
||||
/*13*/ unsigned vFlip:1;
|
||||
/*14*/ unsigned palette:4;
|
||||
};
|
||||
u16 val;
|
||||
};
|
||||
|
||||
bool mosaicOn = (control & 0x40) ? true : false;
|
||||
struct TileLine
|
||||
{
|
||||
u32 pixels[8];
|
||||
};
|
||||
|
||||
int xxx = hofs & maskX;
|
||||
int yyy = (vofs + VCOUNT) & maskY;
|
||||
int mosaicX = (MOSAIC & 0x000F)+1;
|
||||
int mosaicY = ((MOSAIC & 0x00F0)>>4)+1;
|
||||
typedef const TileLine (*TileReader) (const u16 *, const int, const u8 *, u16 *, const u32);
|
||||
|
||||
if(mosaicOn) {
|
||||
if((VCOUNT % mosaicY) != 0) {
|
||||
mosaicY = VCOUNT - (VCOUNT % mosaicY);
|
||||
yyy = (vofs + mosaicY) & maskY;
|
||||
}
|
||||
}
|
||||
static inline void gfxDrawPixel(u32 *dest, const u8 color, const u16 *palette, const u32 prio)
|
||||
{
|
||||
*dest = color ? (READ16LE(&palette[color]) | prio): 0x80000000;
|
||||
}
|
||||
|
||||
if(yyy > 255 && sizeY > 256) {
|
||||
yyy &= 255;
|
||||
screenBase += 0x400;
|
||||
if(sizeX > 256)
|
||||
screenBase += 0x400;
|
||||
}
|
||||
inline const TileLine gfxReadTile(const u16 *screenSource, const int yyy, const u8 *charBase, u16 *palette, const u32 prio)
|
||||
{
|
||||
TileEntry tile;
|
||||
tile.val = READ16LE(screenSource);
|
||||
|
||||
int yshift = ((yyy>>3)<<5);
|
||||
if((control) & 0x80) {
|
||||
u16 *screenSource = screenBase + 0x400 * (xxx>>8) + ((xxx & 255)>>3) + yshift;
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u16 data = READ16LE(screenSource);
|
||||
int tileY = yyy & 7;
|
||||
if (tile.vFlip) tileY = 7 - tileY;
|
||||
TileLine tileLine;
|
||||
|
||||
int tile = data & 0x3FF;
|
||||
int tileX = (xxx & 7);
|
||||
int tileY = yyy & 7;
|
||||
const u8 *tileBase = &charBase[tile.tileNum * 64 + tileY * 8];
|
||||
|
||||
if(tileX == 7)
|
||||
screenSource++;
|
||||
if (!tile.hFlip)
|
||||
{
|
||||
gfxDrawPixel(&tileLine.pixels[0], tileBase[0], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[1], tileBase[1], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[2], tileBase[2], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[3], tileBase[3], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[4], tileBase[4], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[5], tileBase[5], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[6], tileBase[6], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[7], tileBase[7], palette, prio);
|
||||
}
|
||||
else
|
||||
{
|
||||
gfxDrawPixel(&tileLine.pixels[0], tileBase[7], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[1], tileBase[6], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[2], tileBase[5], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[3], tileBase[4], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[4], tileBase[3], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[5], tileBase[2], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[6], tileBase[1], palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[7], tileBase[0], palette, prio);
|
||||
}
|
||||
|
||||
if(data & 0x0400)
|
||||
tileX = 7 - tileX;
|
||||
if(data & 0x0800)
|
||||
tileY = 7 - tileY;
|
||||
return tileLine;
|
||||
}
|
||||
|
||||
u8 color = charBase[tile * 64 + tileY * 8 + tileX];
|
||||
inline const TileLine gfxReadTilePal(const u16 *screenSource, const int yyy, const u8 *charBase, u16 *palette, const u32 prio)
|
||||
{
|
||||
TileEntry tile;
|
||||
tile.val = READ16LE(screenSource);
|
||||
|
||||
line[x] = color ? (READ16LE(&palette[color]) | prio): 0x80000000;
|
||||
int tileY = yyy & 7;
|
||||
if (tile.vFlip) tileY = 7 - tileY;
|
||||
palette += tile.palette * 16;
|
||||
TileLine tileLine;
|
||||
|
||||
xxx++;
|
||||
if(xxx == 256) {
|
||||
if(sizeX > 256)
|
||||
screenSource = screenBase + 0x400 + yshift;
|
||||
else {
|
||||
screenSource = screenBase + yshift;
|
||||
xxx = 0;
|
||||
}
|
||||
} else if(xxx >= sizeX) {
|
||||
xxx = 0;
|
||||
screenSource = screenBase + yshift;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
u16 *screenSource = screenBase + 0x400*(xxx>>8)+((xxx&255)>>3) +
|
||||
yshift;
|
||||
for(int x = 0; x < 240; x++) {
|
||||
u16 data = READ16LE(screenSource);
|
||||
const u8h *tileBase = (u8h*) &charBase[tile.tileNum * 32 + tileY * 4];
|
||||
|
||||
int tile = data & 0x3FF;
|
||||
int tileX = (xxx & 7);
|
||||
int tileY = yyy & 7;
|
||||
if (!tile.hFlip)
|
||||
{
|
||||
gfxDrawPixel(&tileLine.pixels[0], tileBase[0].lo, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[1], tileBase[0].hi, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[2], tileBase[1].lo, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[3], tileBase[1].hi, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[4], tileBase[2].lo, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[5], tileBase[2].hi, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[6], tileBase[3].lo, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[7], tileBase[3].hi, palette, prio);
|
||||
}
|
||||
else
|
||||
{
|
||||
gfxDrawPixel(&tileLine.pixels[0], tileBase[3].hi, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[1], tileBase[3].lo, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[2], tileBase[2].hi, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[3], tileBase[2].lo, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[4], tileBase[1].hi, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[5], tileBase[1].lo, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[6], tileBase[0].hi, palette, prio);
|
||||
gfxDrawPixel(&tileLine.pixels[7], tileBase[0].lo, palette, prio);
|
||||
}
|
||||
|
||||
if(tileX == 7)
|
||||
screenSource++;
|
||||
return tileLine;
|
||||
}
|
||||
|
||||
if(data & 0x0400)
|
||||
tileX = 7 - tileX;
|
||||
if(data & 0x0800)
|
||||
tileY = 7 - tileY;
|
||||
static inline void gfxDrawTile(const TileLine &tileLine, u32 *line)
|
||||
{
|
||||
memcpy(line, tileLine.pixels, sizeof(tileLine.pixels));
|
||||
}
|
||||
|
||||
u8 color = charBase[(tile<<5) + (tileY<<2) + (tileX>>1)];
|
||||
static inline void gfxDrawTileClipped(const TileLine &tileLine, u32 *line, const int start, int w)
|
||||
{
|
||||
memcpy(line, tileLine.pixels + start, w * sizeof(u32));
|
||||
}
|
||||
|
||||
if(tileX & 1) {
|
||||
color = (color >> 4);
|
||||
} else {
|
||||
color &= 0x0F;
|
||||
}
|
||||
template<TileReader readTile>
|
||||
void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs,
|
||||
u32 *line)
|
||||
{
|
||||
u16 *palette = (u16 *)paletteRAM;
|
||||
u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000];
|
||||
u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) * 0x800];
|
||||
u32 prio = ((control & 3)<<25) + 0x1000000;
|
||||
int sizeX = 256;
|
||||
int sizeY = 256;
|
||||
switch ((control >> 14) & 3)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
sizeX = 512;
|
||||
break;
|
||||
case 2:
|
||||
sizeY = 512;
|
||||
break;
|
||||
case 3:
|
||||
sizeX = 512;
|
||||
sizeY = 512;
|
||||
break;
|
||||
}
|
||||
|
||||
int pal = (data>>8) & 0xF0;
|
||||
line[x] = color ? (READ16LE(&palette[pal + color])|prio): 0x80000000;
|
||||
int maskX = sizeX-1;
|
||||
int maskY = sizeY-1;
|
||||
|
||||
xxx++;
|
||||
if(xxx == 256) {
|
||||
if(sizeX > 256)
|
||||
screenSource = screenBase + 0x400 + yshift;
|
||||
else {
|
||||
screenSource = screenBase + yshift;
|
||||
xxx = 0;
|
||||
}
|
||||
} else if(xxx >= sizeX) {
|
||||
xxx = 0;
|
||||
screenSource = screenBase + yshift;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mosaicOn) {
|
||||
if(mosaicX > 1) {
|
||||
int m = 1;
|
||||
for(int i = 0; i < 239; i++) {
|
||||
line[i+1] = line[i];
|
||||
m++;
|
||||
if(m == mosaicX) {
|
||||
m = 1;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool mosaicOn = (control & 0x40) ? true : false;
|
||||
|
||||
int xxx = hofs & maskX;
|
||||
int yyy = (vofs + VCOUNT) & maskY;
|
||||
int mosaicX = (MOSAIC & 0x000F)+1;
|
||||
int mosaicY = ((MOSAIC & 0x00F0)>>4)+1;
|
||||
|
||||
if (mosaicOn)
|
||||
{
|
||||
if ((VCOUNT % mosaicY) != 0)
|
||||
{
|
||||
mosaicY = VCOUNT - (VCOUNT % mosaicY);
|
||||
yyy = (vofs + mosaicY) & maskY;
|
||||
}
|
||||
}
|
||||
|
||||
if (yyy > 255 && sizeY > 256)
|
||||
{
|
||||
yyy &= 255;
|
||||
screenBase += 0x400;
|
||||
if (sizeX > 256)
|
||||
screenBase += 0x400;
|
||||
}
|
||||
|
||||
int yshift = ((yyy>>3)<<5);
|
||||
|
||||
u16 *screenSource = screenBase + 0x400 * (xxx>>8) + ((xxx & 255)>>3) + yshift;
|
||||
int x = 0;
|
||||
const int firstTileX = xxx & 7;
|
||||
|
||||
// First tile, if clipped
|
||||
if (firstTileX)
|
||||
{
|
||||
gfxDrawTileClipped(readTile(screenSource, yyy, charBase, palette, prio), &line[x], firstTileX, 8 - firstTileX);
|
||||
screenSource++;
|
||||
x += 8 - firstTileX;
|
||||
xxx += 8 - firstTileX;
|
||||
}
|
||||
|
||||
// Middle tiles, full
|
||||
while (x < 240 - firstTileX)
|
||||
{
|
||||
gfxDrawTile(readTile(screenSource, yyy, charBase, palette, prio), &line[x]);
|
||||
screenSource++;
|
||||
xxx += 8;
|
||||
x += 8;
|
||||
|
||||
if (xxx == 256 && sizeX > 256)
|
||||
{
|
||||
screenSource = screenBase + 0x400 + yshift;
|
||||
}
|
||||
else if (xxx >= sizeX)
|
||||
{
|
||||
xxx = 0;
|
||||
screenSource = screenBase + yshift;
|
||||
}
|
||||
}
|
||||
|
||||
// Last tile, if clipped
|
||||
if (firstTileX)
|
||||
{
|
||||
gfxDrawTileClipped(readTile(screenSource, yyy, charBase, palette, prio), &line[x], 0, firstTileX);
|
||||
screenSource++;
|
||||
x += firstTileX;
|
||||
xxx += firstTileX;
|
||||
}
|
||||
|
||||
if (mosaicOn)
|
||||
{
|
||||
if (mosaicX > 1)
|
||||
{
|
||||
int m = 1;
|
||||
for (int i = 0; i < 239; i++)
|
||||
{
|
||||
line[i+1] = line[i];
|
||||
m++;
|
||||
if (m == mosaicX)
|
||||
{
|
||||
m = 1;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, u32 *line)
|
||||
{
|
||||
if (control & 0x80) // 1 pal / 256 col
|
||||
gfxDrawTextScreen<gfxReadTile>(control, hofs, vofs, line);
|
||||
else // 16 pal / 16 col
|
||||
gfxDrawTextScreen<gfxReadTilePal>(control, hofs, vofs, line);
|
||||
}
|
||||
|
||||
static inline void gfxDrawRotScreen(u16 control,
|
||||
|
|
|
@ -0,0 +1,227 @@
|
|||
#include "gbafilter.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
extern int systemColorDepth;
|
||||
extern int systemRedShift;
|
||||
extern int systemGreenShift;
|
||||
extern int systemBlueShift;
|
||||
|
||||
extern u16 systemColorMap16[0x10000];
|
||||
extern u32 systemColorMap32[0x10000];
|
||||
|
||||
static const unsigned char curve[32] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x10, 0x12,
|
||||
0x14, 0x16, 0x18, 0x1c, 0x20, 0x28, 0x30, 0x38,
|
||||
0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x80,
|
||||
0x88, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0};
|
||||
|
||||
// output R G B
|
||||
static const unsigned char influence[3 * 3] = { 16, 4, 4, // red
|
||||
8, 16, 8, // green
|
||||
0, 8, 16};// blue
|
||||
|
||||
inline void swap(short & a, short & b)
|
||||
{
|
||||
short temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
void gbafilter_pal(u16 * buf, int count)
|
||||
{
|
||||
short temp[3 * 3], s;
|
||||
unsigned pix;
|
||||
u8 red, green, blue;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
pix = *buf;
|
||||
|
||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||
temp[3] = s * influence[3];
|
||||
temp[4] = s * influence[4];
|
||||
temp[5] = s * influence[5];
|
||||
|
||||
s = curve[(pix >> systemRedShift) & 0x1f];
|
||||
temp[0] = s * influence[0];
|
||||
temp[1] = s * influence[1];
|
||||
temp[2] = s * influence[2];
|
||||
|
||||
s = curve[(pix >> systemBlueShift) & 0x1f];
|
||||
temp[6] = s * influence[6];
|
||||
temp[7] = s * influence[7];
|
||||
temp[8] = s * influence[8];
|
||||
|
||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
||||
temp[3] <<= 1;
|
||||
temp[0] <<= 2;
|
||||
temp[0] += temp[3] + temp[6];
|
||||
|
||||
red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||
if (red > 31) red = 31;
|
||||
|
||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
||||
temp[5] <<= 1;
|
||||
temp[2] <<= 2;
|
||||
temp[2] += temp[5] + temp[8];
|
||||
|
||||
blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||
if (blue > 31) blue = 31;
|
||||
|
||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
||||
temp[4] <<= 1;
|
||||
temp[1] <<= 2;
|
||||
temp[1] += temp[4] + temp[7];
|
||||
|
||||
green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||
if (green > 31) green = 31;
|
||||
|
||||
pix = red << systemRedShift;
|
||||
pix += green << systemGreenShift;
|
||||
pix += blue << systemBlueShift;
|
||||
|
||||
*buf++ = pix;
|
||||
}
|
||||
}
|
||||
|
||||
void gbafilter_pal32(u32 * buf, int count)
|
||||
{
|
||||
short temp[3 * 3], s;
|
||||
unsigned pix;
|
||||
u8 red, green, blue;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
pix = *buf;
|
||||
|
||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||
temp[3] = s * influence[3];
|
||||
temp[4] = s * influence[4];
|
||||
temp[5] = s * influence[5];
|
||||
|
||||
s = curve[(pix >> systemRedShift) & 0x1f];
|
||||
temp[0] = s * influence[0];
|
||||
temp[1] = s * influence[1];
|
||||
temp[2] = s * influence[2];
|
||||
|
||||
s = curve[(pix >> systemBlueShift) & 0x1f];
|
||||
temp[6] = s * influence[6];
|
||||
temp[7] = s * influence[7];
|
||||
temp[8] = s * influence[8];
|
||||
|
||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
||||
temp[3] <<= 1;
|
||||
temp[0] <<= 2;
|
||||
temp[0] += temp[3] + temp[6];
|
||||
|
||||
//red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||
red = ((int(temp[0]) * 160) >> 14) + 32;
|
||||
|
||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
||||
temp[5] <<= 1;
|
||||
temp[2] <<= 2;
|
||||
temp[2] += temp[5] + temp[8];
|
||||
|
||||
//blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||
blue = ((int(temp[2]) * 160) >> 14) + 32;
|
||||
|
||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
||||
temp[4] <<= 1;
|
||||
temp[1] <<= 2;
|
||||
temp[1] += temp[4] + temp[7];
|
||||
|
||||
//green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||
green = ((int(temp[1]) * 160) >> 14) + 32;
|
||||
|
||||
//pix = red << redshift;
|
||||
//pix += green << greenshift;
|
||||
//pix += blue << blueshift;
|
||||
|
||||
pix = red << (systemRedShift - 3);
|
||||
pix += green << (systemGreenShift - 3);
|
||||
pix += blue << (systemBlueShift - 3);
|
||||
|
||||
*buf++ = pix;
|
||||
}
|
||||
}
|
||||
|
||||
// for palette mode to work with the three spoony filters in 32bpp depth
|
||||
|
||||
void gbafilter_pad(u8 * buf, int count)
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u8 r;
|
||||
u8 g;
|
||||
u8 b;
|
||||
u8 a;
|
||||
} part;
|
||||
unsigned whole;
|
||||
}
|
||||
mask;
|
||||
|
||||
mask.whole = 0x1f << systemRedShift;
|
||||
mask.whole += 0x1f << systemGreenShift;
|
||||
mask.whole += 0x1f << systemBlueShift;
|
||||
|
||||
switch (systemColorDepth)
|
||||
{
|
||||
case 24:
|
||||
while (count--)
|
||||
{
|
||||
*buf++ &= mask.part.r;
|
||||
*buf++ &= mask.part.g;
|
||||
*buf++ &= mask.part.b;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
while (count--)
|
||||
{
|
||||
*((u32*)buf) &= mask.whole;
|
||||
buf += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void UpdateSystemColorMaps(int lcd)
|
||||
{
|
||||
switch(systemColorDepth) {
|
||||
case 16:
|
||||
{
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd == 1) gbafilter_pal(systemColorMap16, 0x10000);
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
{
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd == 1) gbafilter_pal32(systemColorMap32, 0x10000);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,5 @@
|
|||
#include "../System.h"
|
||||
|
||||
void gbafilter_pal(u16 * buf, int count);
|
||||
void gbafilter_pal32(u32 * buf, int count);
|
||||
void gbafilter_pad(u8 * buf, int count);
|
|
@ -274,7 +274,7 @@ bool Direct3DDisplay::initialize()
|
|||
return false;
|
||||
}
|
||||
theApp.fsColorDepth = systemColorDepth;
|
||||
utilUpdateSystemColorMaps();
|
||||
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
||||
|
||||
|
||||
#ifdef MMX
|
||||
|
|
|
@ -378,8 +378,6 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd)
|
|||
ON_MESSAGE(WM_SYSCOMMAND, OnMySysCommand)
|
||||
ON_COMMAND(ID_OPTIONS_SOUND_HARDWAREACCELERATION, &MainWnd::OnOptionsSoundHardwareacceleration)
|
||||
ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_HARDWAREACCELERATION, &MainWnd::OnUpdateOptionsSoundHardwareacceleration)
|
||||
ON_COMMAND(ID_OPTIONS_FILTER_LCDCOLORS, OnOptionsFilterLcdcolors)
|
||||
ON_UPDATE_COMMAND_UI(ID_OPTIONS_FILTER_LCDCOLORS, OnUpdateOptionsFilterLcdcolors)
|
||||
ON_COMMAND(ID_OUTPUTAPI_DIRECTSOUND, &MainWnd::OnOutputapiDirectsound)
|
||||
ON_UPDATE_COMMAND_UI(ID_OUTPUTAPI_DIRECTSOUND, &MainWnd::OnUpdateOutputapiDirectsound)
|
||||
ON_COMMAND(ID_OUTPUTAPI_OPENAL, &MainWnd::OnOutputapiOpenal)
|
||||
|
|
|
@ -325,8 +325,6 @@ protected:
|
|||
afx_msg BOOL OnFileRecentFile(UINT nID);
|
||||
afx_msg BOOL OnFileLoadSlot(UINT nID);
|
||||
afx_msg BOOL OnFileSaveSlot(UINT nID);
|
||||
afx_msg void OnOptionsFilterLcdcolors();
|
||||
afx_msg void OnUpdateOptionsFilterLcdcolors(CCmdUI *pCmdUI);
|
||||
afx_msg void OnOptionsSoundHardwareacceleration();
|
||||
afx_msg void OnUpdateOptionsSoundHardwareacceleration(CCmdUI *pCmdUI);
|
||||
afx_msg void OnLinkOptions();
|
||||
|
|
|
@ -1105,6 +1105,7 @@ void MainWnd::OnUpdateOptionsGameboyGb(CCmdUI* pCmdUI)
|
|||
void MainWnd::OnOptionsGameboyRealcolors()
|
||||
{
|
||||
gbColorOption = 0;
|
||||
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
||||
}
|
||||
|
||||
void MainWnd::OnUpdateOptionsGameboyRealcolors(CCmdUI* pCmdUI)
|
||||
|
@ -1115,6 +1116,7 @@ void MainWnd::OnUpdateOptionsGameboyRealcolors(CCmdUI* pCmdUI)
|
|||
void MainWnd::OnOptionsGameboyGameboycolors()
|
||||
{
|
||||
gbColorOption = 1;
|
||||
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
||||
}
|
||||
|
||||
void MainWnd::OnUpdateOptionsGameboyGameboycolors(CCmdUI* pCmdUI)
|
||||
|
@ -1363,18 +1365,6 @@ void MainWnd::OnUpdateOptionsFilterDisablemmx(CCmdUI* pCmdUI)
|
|||
pCmdUI->SetCheck(theApp.disableMMX);
|
||||
}
|
||||
|
||||
void MainWnd::OnOptionsFilterLcdcolors()
|
||||
{
|
||||
// todo: depreciated
|
||||
theApp.filterLCD = !theApp.filterLCD;
|
||||
utilUpdateSystemColorMaps();
|
||||
}
|
||||
|
||||
void MainWnd::OnUpdateOptionsFilterLcdcolors(CCmdUI *pCmdUI)
|
||||
{
|
||||
pCmdUI->SetCheck(theApp.filterLCD);
|
||||
}
|
||||
|
||||
void MainWnd::OnOptionsLanguageSystem()
|
||||
{
|
||||
theApp.winSetLanguageOption(0, false);
|
||||
|
|
|
@ -353,7 +353,7 @@ bool OpenGLDisplay::initialize()
|
|||
|
||||
Init_2xSaI(32);
|
||||
|
||||
utilUpdateSystemColorMaps();
|
||||
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
||||
theApp.updateFilter();
|
||||
theApp.updateIFB();
|
||||
pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
|
||||
|
|
|
@ -609,7 +609,7 @@ void VBA::updateFilter()
|
|||
systemRedShift = realsystemRedShift;
|
||||
systemGreenShift = realsystemGreenShift;
|
||||
systemBlueShift = realsystemBlueShift;
|
||||
utilUpdateSystemColorMaps();
|
||||
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
||||
}
|
||||
// END hacky ugly code
|
||||
|
||||
|
@ -829,7 +829,7 @@ void VBA::updateFilter()
|
|||
systemGreenShift = 6;
|
||||
realsystemBlueShift = systemBlueShift;
|
||||
systemBlueShift = 0;
|
||||
utilUpdateSystemColorMaps();
|
||||
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
||||
}
|
||||
|
||||
#ifdef LOG_PERFORMANCE
|
||||
|
@ -2464,8 +2464,6 @@ void VBA::saveSettings()
|
|||
|
||||
regSetDwordValue("filterEnableMultiThreading", filterMT ? 1 : 0);
|
||||
|
||||
regSetDwordValue("LCDFilter", filterLCD);
|
||||
|
||||
regSetDwordValue("disableMMX", disableMMX);
|
||||
|
||||
regSetDwordValue("disableStatus", disableStatusMessage);
|
||||
|
|
|
@ -70,7 +70,6 @@ class VBA : public CWinApp
|
|||
int filterWidth;
|
||||
int filterHeight;
|
||||
int filterMagnification;
|
||||
int filterLCD;
|
||||
bool filterMT; // enable multi-threading for pixel filters
|
||||
int fsWidth;
|
||||
int fsHeight;
|
||||
|
|
|
@ -1918,7 +1918,6 @@ BEGIN
|
|||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Real Colors", ID_OPTIONS_GAMEBOY_REALCOLORS
|
||||
MENUITEM "G&ameboy Colors", ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS
|
||||
MENUITEM "LCD colors", ID_OPTIONS_FILTER_LCDCOLORS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Colors...", ID_OPTIONS_GAMEBOY_COLORS
|
||||
END
|
||||
|
|
|
@ -808,7 +808,6 @@
|
|||
#define ID_OPTIONS_SOUND_PCMINTERPOLATION_CUBIC 40296
|
||||
#define ID_OPTIONS_SOUND_PCMINTERPOLATION_FIR 40297
|
||||
#define ID_OPTIONS_SOUND_PCMINTERPOLATION_LIBRESAMPLE 40298
|
||||
#define ID_OPTIONS_FILTER_LCDCOLORS 40299
|
||||
#define IDD_LINKTAB1 40300
|
||||
#define IDD_LINKTAB 40301
|
||||
#define IDD_LINKTAB2 40302
|
||||
|
|
Loading…
Reference in New Issue