diff options
Diffstat (limited to 'backends/platform/ds/arm9/source/osystem_ds.cpp')
-rw-r--r-- | backends/platform/ds/arm9/source/osystem_ds.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 9ff2c5ba63..cad6ad6b78 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -173,8 +173,8 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int u16* src = (u16 *) buf; if (DS::getKeyboardEnable()) { - - for (int dy = y; dy < y + h; dy++) { + for (int dy = y; dy < y + h; dy++) + { u16* dest = bg + (dy << 8) + (x >> 1); DC_FlushRange(src, w << 1); @@ -185,7 +185,8 @@ void OSystem_DS::copyRectToScreen(const byte *buf, int pitch, int x, int y, int } } else { - for (int dy = y; dy < y + h; dy++) { + for (int dy = y; dy < y + h; dy++) + { u16* dest1 = bg + (dy << 8) + (x >> 1); u16* dest2 = bgSub + (dy << 8) + (x >> 1); @@ -473,22 +474,36 @@ Common::SaveFileManager* OSystem_DS::getSavefileManager() } } -bool OSystem_DS::grabRawScreen(Graphics::Surface* surf) { - surf->create(DS::getGameWidth(), DS::getGameHeight(), 1); +Graphics::Surface *OSystem_DS::lockScreen() { + // For now, we create a full temporary screen surface, to which we copy the + // the screen content. Later unlockScreen will copy everything back. + // Not very nice nor efficient, but at least works, and is not worse + // than in the bad old times where we used grabRawScreen + copyRectToScreen. + + _framebuffer.create(DS::getGameWidth(), DS::getGameHeight(), 1); // Ensure we copy using 16 bit quantities due to limitation of VRAM addressing - // TODO: Change this to work with the software scalar (hint: video ram format is different) + + u16* image = (u16 *) DS::get8BitBackBuffer(); for (int y = 0; y < DS::getGameHeight(); y++) { - DC_FlushRange((image + (y * 512)), DS::getGameWidth()); + DC_FlushRange(image + (y << 8), DS::getGameWidth()); for (int x = 0; x < DS::getGameWidth() >> 1; x++) { - *(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = *(image + y * 256 + x); + *(((u16 *) (_framebuffer.pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[y << 8 + x]; } } - return true; + return &_framebuffer; +} + +void OSystem_DS::unlockScreen() { + // Copy temp framebuffer back to screen + copyRectToScreen((byte *)_framebuffer.pixels, _framebuffer.pitch, 0, 0, _framebuffer.w, _framebuffer.h); + + // Free memory + _framebuffer.free(); } void OSystem_DS::setFocusRectangle(const Common::Rect& rect) { |