aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorBertrand Augereau2007-06-07 20:34:15 +0000
committerBertrand Augereau2007-06-07 20:34:15 +0000
commita7271cb9dd6fedabea6ce12dc8de249cc220b284 (patch)
tree804d9a4ba1a81ffa54c9cdad22c87a833063bf30 /backends
parentc7169a36ff5f0b2eacdd04b1c3bfb38d16be3045 (diff)
downloadscummvm-rg350-a7271cb9dd6fedabea6ce12dc8de249cc220b284.tar.gz
scummvm-rg350-a7271cb9dd6fedabea6ce12dc8de249cc220b284.tar.bz2
scummvm-rg350-a7271cb9dd6fedabea6ce12dc8de249cc220b284.zip
NDS : Attempt to not buffer overrun VRAM when doing saveGameBackBuffer/restoreGameBackBuffer when CPU scaler is on
svn-id: r27176
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/ds/arm9/source/dsmain.cpp46
1 files changed, 34 insertions, 12 deletions
diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp
index 153ecfab87..21602c4f34 100644
--- a/backends/platform/ds/arm9/source/dsmain.cpp
+++ b/backends/platform/ds/arm9/source/dsmain.cpp
@@ -333,27 +333,49 @@ void initSprites() {
void saveGameBackBuffer() {
#ifdef DISABLE_SCUMM
if (savedBuffer == NULL) savedBuffer = new u8[gameWidth * gameHeight];
- for (int r = 0; r < 200; r++) {
- memcpy(savedBuffer + (r * gameWidth), ((u8 *) (get8BitBackBuffer())) + (r * 512), gameWidth);
+ if(isCpuScalerEnabled())
+ {
+ memcpy(savedBuffer, get8BitBackBuffer(), gameWidth * gameHeight);
}
+ else
+ {
+ for (int r = 0; r < gameHeight; r++) {
+ memcpy(savedBuffer + (r * gameWidth), ((u8 *) (get8BitBackBuffer())) + (r * 512), gameWidth);
+ }
+ }
#endif
}
void restoreGameBackBuffer() {
#ifdef DISABLE_SCUMM
if (savedBuffer) {
- for (int r = 0; r < 200; r++) {
- memcpy(((u8 *) (BG_GFX_SUB)) + (r * 512), savedBuffer + (r * gameWidth), gameWidth);
- memcpy(((u8 *) (get8BitBackBuffer())) + (r * 512), savedBuffer + (r * gameWidth), gameWidth);
- }
+ if(isCpuScalerEnabled())
+ {
+ memcpy(get8BitBackBuffer(), savedBuffer, gameWidth * gameHeight);
+ // TODO Synchronize with framebuffer if necessary
+ }
+ else
+ {
+ for (int r = 0; r < gameHeight; r++) {
+ memcpy(((u8 *) (BG_GFX_SUB)) + (r * 512), savedBuffer + (r * gameWidth), gameWidth);
+ memcpy(((u8 *) (get8BitBackBuffer())) + (r * 512), savedBuffer + (r * gameWidth), gameWidth);
+ }
+ }
+
delete savedBuffer;
savedBuffer = NULL;
}
-#endif
-
-#ifndef DISABLE_SCUMM
- memset(get8BitBackBuffer(), 0, 512 * 256);
- memset(BG_GFX_SUB, 0, 512 * 256);
+#else
+ if(isCpuScalerEnabled())
+ {
+ memset(get8BitBackBuffer(), 0, 320 * 200);
+ // TODO Synchronize with framebuffer if necessary
+ }
+ else
+ {
+ memset(get8BitBackBuffer(), 0, 512 * 256);
+ memset(BG_GFX_SUB, 0, 512 * 256);
+ }
if (Scumm::g_scumm) {
Scumm::g_scumm->markRectAsDirty(Scumm::kMainVirtScreen, 0, gameWidth - 1, 0, gameHeight - 1, 1);
Scumm::g_scumm->markRectAsDirty(Scumm::kTextVirtScreen, 0, gameWidth - 1, 0, gameHeight - 1, 1);
@@ -728,7 +750,7 @@ void displayMode16BitFlipBuffer() {
}
else if (isCpuScalerEnabled())
{
- //#define SCALER_PROFILE
+ #define SCALER_PROFILE
#ifdef SCALER_PROFILE
TIMER1_CR = TIMER_ENABLE | TIMER_DIV_1024;