The OpenGL code now uses 32-bit textures. This is required for

blending in conjunction with phosphor effect.

For the Chetiry scheme, when loading or saving the 64 byte score
table, we now ignore the first 4 bytes (as specified by the
documentation).  These 4 bytes/addresses are actually a type of hotspot.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2489 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2012-05-20 21:10:19 +00:00
parent 4281ac2436
commit ad8dd1d27e
4 changed files with 29 additions and 29 deletions

View File

@ -66,18 +66,18 @@ FBSurfaceGL::~FBSurfaceGL()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::hLine(uInt32 x, uInt32 y, uInt32 x2, uInt32 color) void FBSurfaceGL::hLine(uInt32 x, uInt32 y, uInt32 x2, uInt32 color)
{ {
uInt16* buffer = (uInt16*) myTexture->pixels + y * myPitch + x; uInt32* buffer = (uInt32*) myTexture->pixels + y * myPitch + x;
while(x++ <= x2) while(x++ <= x2)
*buffer++ = (uInt16) myFB.myDefPalette[color]; *buffer++ = (uInt32) myFB.myDefPalette[color];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::vLine(uInt32 x, uInt32 y, uInt32 y2, uInt32 color) void FBSurfaceGL::vLine(uInt32 x, uInt32 y, uInt32 y2, uInt32 color)
{ {
uInt16* buffer = (uInt16*) myTexture->pixels + y * myPitch + x; uInt32* buffer = (uInt32*) myTexture->pixels + y * myPitch + x;
while(y++ <= y2) while(y++ <= y2)
{ {
*buffer = (uInt16) myFB.myDefPalette[color]; *buffer = (uInt32) myFB.myDefPalette[color];
buffer += myPitch; buffer += myPitch;
} }
} }
@ -126,7 +126,7 @@ void FBSurfaceGL::drawChar(const GUI::Font& font, uInt8 chr,
} }
const uInt16* tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.fbbh)); const uInt16* tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.fbbh));
uInt16* buffer = (uInt16*) myTexture->pixels + uInt32* buffer = (uInt32*) myTexture->pixels +
(ty + desc.ascent - bby - bbh) * myPitch + (ty + desc.ascent - bby - bbh) * myPitch +
tx + bbx; tx + bbx;
@ -137,7 +137,7 @@ void FBSurfaceGL::drawChar(const GUI::Font& font, uInt8 chr,
for(int x = 0; x < bbw; x++, mask >>= 1) for(int x = 0; x < bbw; x++, mask >>= 1)
if(ptr & mask) if(ptr & mask)
buffer[x] = (uInt16) myFB.myDefPalette[color]; buffer[x] = (uInt32) myFB.myDefPalette[color];
buffer += myPitch; buffer += myPitch;
} }
@ -147,14 +147,14 @@ void FBSurfaceGL::drawChar(const GUI::Font& font, uInt8 chr,
void FBSurfaceGL::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty, void FBSurfaceGL::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty,
uInt32 color, uInt32 h) uInt32 color, uInt32 h)
{ {
uInt16* buffer = (uInt16*) myTexture->pixels + ty * myPitch + tx; uInt32* buffer = (uInt32*) myTexture->pixels + ty * myPitch + tx;
for(uInt32 y = 0; y < h; ++y) for(uInt32 y = 0; y < h; ++y)
{ {
uInt32 mask = 0xF0000000; uInt32 mask = 0xF0000000;
for(uInt32 x = 0; x < 8; ++x, mask >>= 4) for(uInt32 x = 0; x < 8; ++x, mask >>= 4)
if(bitmap[y] & mask) if(bitmap[y] & mask)
buffer[x] = (uInt16) myFB.myDefPalette[color]; buffer[x] = (uInt32) myFB.myDefPalette[color];
buffer += myPitch; buffer += myPitch;
} }
@ -163,10 +163,10 @@ void FBSurfaceGL::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::drawPixels(uInt32* data, uInt32 tx, uInt32 ty, uInt32 numpixels) void FBSurfaceGL::drawPixels(uInt32* data, uInt32 tx, uInt32 ty, uInt32 numpixels)
{ {
uInt16* buffer = (uInt16*) myTexture->pixels + ty * myPitch + tx; uInt32* buffer = (uInt32*) myTexture->pixels + ty * myPitch + tx;
for(uInt32 i = 0; i < numpixels; ++i) for(uInt32 i = 0; i < numpixels; ++i)
*buffer++ = (uInt16) data[i]; *buffer++ = (uInt32) data[i];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -257,7 +257,7 @@ void FBSurfaceGL::update()
myGL.ActiveTexture(GL_TEXTURE0); myGL.ActiveTexture(GL_TEXTURE0);
myGL.BindTexture(GL_TEXTURE_2D, myTexID); myGL.BindTexture(GL_TEXTURE_2D, myTexID);
myGL.TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, myTexWidth, myTexHeight, myGL.TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, myTexWidth, myTexHeight,
GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
myTexture->pixels); myTexture->pixels);
myGL.EnableClientState(GL_VERTEX_ARRAY); myGL.EnableClientState(GL_VERTEX_ARRAY);
@ -313,8 +313,8 @@ void FBSurfaceGL::reload()
myGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); myGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Create the texture in the most optimal format // Create the texture in the most optimal format
myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, myTexWidth, myTexHeight, 0, myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, myTexWidth, myTexHeight, 0,
GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
myTexture->pixels); myTexture->pixels);
// Cache vertex and texture coordinates using vertex buffer object // Cache vertex and texture coordinates using vertex buffer object

View File

@ -87,7 +87,7 @@ void FBSurfaceTIA::update()
uInt8* previousFrame = myTIA->previousFrameBuffer(); uInt8* previousFrame = myTIA->previousFrameBuffer();
uInt32 width = myTIA->width(); uInt32 width = myTIA->width();
uInt32 height = myTIA->height(); uInt32 height = myTIA->height();
uInt16* buffer = (uInt16*) myTexture->pixels; uInt32* buffer = (uInt32*) myTexture->pixels;
// TODO - Eventually 'phosphor' won't be a separate mode, and will become // TODO - Eventually 'phosphor' won't be a separate mode, and will become
// a post-processing filter by blending several frames. // a post-processing filter by blending several frames.
@ -101,7 +101,7 @@ void FBSurfaceTIA::update()
{ {
uInt32 pos = screenofsY; uInt32 pos = screenofsY;
for(uInt32 x = 0; x < width; ++x) for(uInt32 x = 0; x < width; ++x)
buffer[pos++] = (uInt16) myFB.myDefPalette[currentFrame[bufofsY + x]]; buffer[pos++] = (uInt32) myFB.myDefPalette[currentFrame[bufofsY + x]];
bufofsY += width; bufofsY += width;
screenofsY += myPitch; screenofsY += myPitch;
@ -119,7 +119,7 @@ void FBSurfaceTIA::update()
for(uInt32 x = 0; x < width; ++x) for(uInt32 x = 0; x < width; ++x)
{ {
const uInt32 bufofs = bufofsY + x; const uInt32 bufofs = bufofsY + x;
buffer[pos++] = (uInt16) buffer[pos++] = (uInt32)
myFB.myAvgPalette[currentFrame[bufofs]][previousFrame[bufofs]]; myFB.myAvgPalette[currentFrame[bufofs]][previousFrame[bufofs]];
} }
bufofsY += width; bufofsY += width;
@ -130,7 +130,7 @@ void FBSurfaceTIA::update()
case FrameBufferGL::kBlarggNTSC: case FrameBufferGL::kBlarggNTSC:
{ {
myFB.myNTSCFilter.blit_1555 myFB.myNTSCFilter.blit_8888
(currentFrame, width, height, buffer, myTexture->pitch); (currentFrame, width, height, buffer, myTexture->pitch);
break; break;
} }
@ -143,7 +143,7 @@ void FBSurfaceTIA::update()
myGL.ActiveTexture(GL_TEXTURE0); myGL.ActiveTexture(GL_TEXTURE0);
myGL.BindTexture(GL_TEXTURE_2D, myTexID[0]); myGL.BindTexture(GL_TEXTURE_2D, myTexID[0]);
myGL.TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, myTexWidth, myTexHeight, myGL.TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, myTexWidth, myTexHeight,
GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
myTexture->pixels); myTexture->pixels);
if(myFB.myVBOAvailable) if(myFB.myVBOAvailable)
@ -225,8 +225,8 @@ void FBSurfaceTIA::reload()
myGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); myGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Create the texture in the most optimal format // Create the texture in the most optimal format
myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, myTexWidth, myTexHeight, 0, myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, myTexWidth, myTexHeight, 0,
GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
myTexture->pixels); myTexture->pixels);
// Scanline texture (@ index 1) // Scanline texture (@ index 1)
@ -236,9 +236,9 @@ void FBSurfaceTIA::reload()
myGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); myGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
myGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); myGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
static uInt16 const scanline[4] = { 0x0000, 0x0000, 0x8000, 0x0000 }; static uInt32 const scanline[2] = { 0x00000000, 0xff000000 };
myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 2, 0, myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 2, 0,
GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
scanline); scanline);
// Cache vertex and texture coordinates using vertex buffer object // Cache vertex and texture coordinates using vertex buffer object

View File

@ -48,8 +48,8 @@ FrameBufferGL::FrameBufferGL(OSystem* osystem)
// It's done this way (vs directly accessing a FBSurfaceGL object) // It's done this way (vs directly accessing a FBSurfaceGL object)
// since the structure may be needed before any FBSurface's have // since the structure may be needed before any FBSurface's have
// been created // been created
SDL_Surface* s = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, 1, 16, SDL_Surface* s = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, 1, 32,
0x00007c00, 0x000003e0, 0x0000001f, 0x00000000); 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
myPixelFormat = *(s->format); myPixelFormat = *(s->format);
SDL_FreeSurface(s); SDL_FreeSurface(s);

View File

@ -423,8 +423,8 @@ void CartridgeCTY::loadScore(uInt8 index)
{ {
memset(scoreRAM, 0, 256); memset(scoreRAM, 0, 256);
} }
// Grab 64B slice @ given index // Grab 60B slice @ given index (first 4 bytes are ignored)
memcpy(myRAM, scoreRAM + (index << 6), 64); memcpy(myRAM+4, scoreRAM + (index << 6) + 4, 60);
} }
} }
@ -445,8 +445,8 @@ void CartridgeCTY::saveScore(uInt8 index)
memset(scoreRAM, 0, 256); memset(scoreRAM, 0, 256);
} }
// Add 64B RAM to score table @ given index // Add 60B RAM to score table @ given index (first 4 bytes are ignored)
memcpy(scoreRAM + (index << 6), myRAM, 64); memcpy(scoreRAM + (index << 6) + 4, myRAM+4, 60);
// Save score RAM // Save score RAM
serializer.reset(); serializer.reset();