From ad8dd1d27ebc9dad64864d8e88fc8e7e6716dc83 Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 20 May 2012 21:10:19 +0000 Subject: [PATCH] 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 --- src/common/FBSurfaceGL.cxx | 26 +++++++++++++------------- src/common/FBSurfaceTIA.cxx | 20 ++++++++++---------- src/common/FrameBufferGL.cxx | 4 ++-- src/emucore/CartCTY.cxx | 8 ++++---- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/common/FBSurfaceGL.cxx b/src/common/FBSurfaceGL.cxx index b0849361c..16c8423c4 100644 --- a/src/common/FBSurfaceGL.cxx +++ b/src/common/FBSurfaceGL.cxx @@ -66,18 +66,18 @@ FBSurfaceGL::~FBSurfaceGL() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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) - *buffer++ = (uInt16) myFB.myDefPalette[color]; + *buffer++ = (uInt32) myFB.myDefPalette[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) { - *buffer = (uInt16) myFB.myDefPalette[color]; + *buffer = (uInt32) myFB.myDefPalette[color]; 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)); - uInt16* buffer = (uInt16*) myTexture->pixels + + uInt32* buffer = (uInt32*) myTexture->pixels + (ty + desc.ascent - bby - bbh) * myPitch + tx + bbx; @@ -137,7 +137,7 @@ void FBSurfaceGL::drawChar(const GUI::Font& font, uInt8 chr, for(int x = 0; x < bbw; x++, mask >>= 1) if(ptr & mask) - buffer[x] = (uInt16) myFB.myDefPalette[color]; + buffer[x] = (uInt32) myFB.myDefPalette[color]; buffer += myPitch; } @@ -147,14 +147,14 @@ void FBSurfaceGL::drawChar(const GUI::Font& font, uInt8 chr, void FBSurfaceGL::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty, 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) { uInt32 mask = 0xF0000000; for(uInt32 x = 0; x < 8; ++x, mask >>= 4) if(bitmap[y] & mask) - buffer[x] = (uInt16) myFB.myDefPalette[color]; + buffer[x] = (uInt32) myFB.myDefPalette[color]; 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) { - uInt16* buffer = (uInt16*) myTexture->pixels + ty * myPitch + tx; + uInt32* buffer = (uInt32*) myTexture->pixels + ty * myPitch + tx; 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.BindTexture(GL_TEXTURE_2D, myTexID); 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); 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); // Create the texture in the most optimal format - myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, myTexWidth, myTexHeight, 0, - GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, + myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, myTexWidth, myTexHeight, 0, + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, myTexture->pixels); // Cache vertex and texture coordinates using vertex buffer object diff --git a/src/common/FBSurfaceTIA.cxx b/src/common/FBSurfaceTIA.cxx index 7b616cdc5..7034a3203 100644 --- a/src/common/FBSurfaceTIA.cxx +++ b/src/common/FBSurfaceTIA.cxx @@ -87,7 +87,7 @@ void FBSurfaceTIA::update() uInt8* previousFrame = myTIA->previousFrameBuffer(); uInt32 width = myTIA->width(); 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 // a post-processing filter by blending several frames. @@ -101,7 +101,7 @@ void FBSurfaceTIA::update() { uInt32 pos = screenofsY; 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; screenofsY += myPitch; @@ -119,7 +119,7 @@ void FBSurfaceTIA::update() for(uInt32 x = 0; x < width; ++x) { const uInt32 bufofs = bufofsY + x; - buffer[pos++] = (uInt16) + buffer[pos++] = (uInt32) myFB.myAvgPalette[currentFrame[bufofs]][previousFrame[bufofs]]; } bufofsY += width; @@ -130,7 +130,7 @@ void FBSurfaceTIA::update() case FrameBufferGL::kBlarggNTSC: { - myFB.myNTSCFilter.blit_1555 + myFB.myNTSCFilter.blit_8888 (currentFrame, width, height, buffer, myTexture->pitch); break; } @@ -143,7 +143,7 @@ void FBSurfaceTIA::update() myGL.ActiveTexture(GL_TEXTURE0); myGL.BindTexture(GL_TEXTURE_2D, myTexID[0]); 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); if(myFB.myVBOAvailable) @@ -225,8 +225,8 @@ void FBSurfaceTIA::reload() myGL.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Create the texture in the most optimal format - myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, myTexWidth, myTexHeight, 0, - GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, + myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, myTexWidth, myTexHeight, 0, + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, myTexture->pixels); // 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_T, GL_REPEAT); - static uInt16 const scanline[4] = { 0x0000, 0x0000, 0x8000, 0x0000 }; - myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 2, 0, - GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, + static uInt32 const scanline[2] = { 0x00000000, 0xff000000 }; + myGL.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 2, 0, + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, scanline); // Cache vertex and texture coordinates using vertex buffer object diff --git a/src/common/FrameBufferGL.cxx b/src/common/FrameBufferGL.cxx index 83523c1db..1e3119f54 100644 --- a/src/common/FrameBufferGL.cxx +++ b/src/common/FrameBufferGL.cxx @@ -48,8 +48,8 @@ FrameBufferGL::FrameBufferGL(OSystem* osystem) // It's done this way (vs directly accessing a FBSurfaceGL object) // since the structure may be needed before any FBSurface's have // been created - SDL_Surface* s = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, 1, 16, - 0x00007c00, 0x000003e0, 0x0000001f, 0x00000000); + SDL_Surface* s = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, 1, 32, + 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); myPixelFormat = *(s->format); SDL_FreeSurface(s); diff --git a/src/emucore/CartCTY.cxx b/src/emucore/CartCTY.cxx index 7da72e123..8e793eddc 100644 --- a/src/emucore/CartCTY.cxx +++ b/src/emucore/CartCTY.cxx @@ -423,8 +423,8 @@ void CartridgeCTY::loadScore(uInt8 index) { memset(scoreRAM, 0, 256); } - // Grab 64B slice @ given index - memcpy(myRAM, scoreRAM + (index << 6), 64); + // Grab 60B slice @ given index (first 4 bytes are ignored) + memcpy(myRAM+4, scoreRAM + (index << 6) + 4, 60); } } @@ -445,8 +445,8 @@ void CartridgeCTY::saveScore(uInt8 index) memset(scoreRAM, 0, 256); } - // Add 64B RAM to score table @ given index - memcpy(scoreRAM + (index << 6), myRAM, 64); + // Add 60B RAM to score table @ given index (first 4 bytes are ignored) + memcpy(scoreRAM + (index << 6) + 4, myRAM+4, 60); // Save score RAM serializer.reset();