Package: blobwars Version: 1.05-2 Severity: normal Tags: patch Blobwars uses a busy-loop for timing purposes. This makes it use 100% CPU all the time, even when it is not doing anything useful. The attached patch removes the busy-loops and replaces them with calls to SDL_Delay().
-- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.16.11 Locale: LANG=nl_NL.UTF-8, LC_CTYPE=nl_NL.UTF-8 (charmap=UTF-8) Versions of packages blobwars depends on: ii libc6 2.3.6-7 GNU C Library: Shared libraries ii libgcc1 1:4.1.0-1 GCC support library ii libsdl-image1.2 1.2.4-1 image loading library for Simple D ii libsdl-mixer1.2 1.2.6-1.1 mixer library for Simple DirectMed ii libsdl-ttf2.0-0 2.0.7-1 ttf library for Simple DirectMedia ii libsdl1.2debian 1.2.9-5+b1 Simple DirectMedia Layer ii libstdc++6 4.1.0-1 The GNU Standard C++ Library v3 ii zlib1g 1:1.2.3-11 compression library - runtime blobwars recommends no packages. -- no debconf information
--- blobwars-1.04.orig/src/mapEditor.cpp +++ blobwars-1.04/src/mapEditor.cpp @@ -115,6 +115,8 @@ graphics.drawRect(*mapX, *mapY, 1, 15, graphics.green, graphics.screen); graphics.drawRect(*mapX, *mapY + 15, 20, 1, graphics.green, graphics.screen); graphics.drawRect(*mapX + 20, *mapY, 1, 15, graphics.green, graphics.screen); + + SDL_Delay(16); } engine.keyState[SDLK_SPACE] = 0; @@ -632,7 +634,7 @@ graphics.drawString(string, 320, r.y + 5, true, graphics.screen); - while (SDL_GetTicks() < frameLimit){} + SDL_Delay(frameLimit - SDL_GetTicks() >? 0 <? 16); frameLimit = SDL_GetTicks() + 16; } --- blobwars-1.04.orig/src/mission.cpp +++ blobwars-1.04/src/mission.cpp @@ -357,7 +357,7 @@ sprintf(message, "%s - %.2d:%.2d:%.2d", "Mission Time", game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds); graphics.drawString(message, 320, 420, true, graphics.screen); - while (SDL_GetTicks() < frameLimit){} + SDL_Delay(frameLimit - SDL_GetTicks() >? 0 <? 16); frameLimit = SDL_GetTicks() + 16; } --- blobwars-1.04.orig/src/map.cpp +++ blobwars-1.04/src/map.cpp @@ -434,6 +434,8 @@ break; } } + + SDL_Delay(16); } blipList.clear(); --- blobwars-1.04.orig/src/CGraphics.cpp +++ blobwars-1.04/src/CGraphics.cpp @@ -195,6 +195,8 @@ { break; } + + SDL_Delay(16); } } @@ -1039,6 +1041,7 @@ engine->getInput(); if (engine->keyState[SDLK_ESCAPE]) exit(1); + SDL_Delay(16); } } @@ -1087,6 +1090,7 @@ { exit(1); } + SDL_Delay(16); } } @@ -1119,5 +1123,7 @@ { exit(0); } + + SDL_Delay(16); } } --- blobwars-1.04.orig/src/loadSave.cpp +++ blobwars-1.04/src/loadSave.cpp @@ -302,6 +302,8 @@ { break; } + + SDL_Delay(16); } SDL_FillRect(graphics.screen, NULL, graphics.black); --- blobwars-1.04.orig/src/title.cpp +++ blobwars-1.04/src/title.cpp @@ -401,7 +401,7 @@ break; } - while (SDL_GetTicks() < (frameLimit)){} + SDL_Delay(frameLimit - SDL_GetTicks() >? 0 <? 16); frameLimit = SDL_GetTicks() + 16; } @@ -545,6 +545,8 @@ graphics.drawRect(0, 450, 640, 30, graphics.black, graphics.screen); graphics.drawRect(0, 0, 640, 30, graphics.black, graphics.screen); } + + SDL_Delay(16); } graphics.delay(12000); --- blobwars-1.04.orig/src/intro.cpp +++ blobwars-1.04/src/intro.cpp @@ -81,7 +81,7 @@ if (SDL_GetTicks() > time) break; - while (SDL_GetTicks() < frameLimit){} + SDL_Delay(frameLimit - SDL_GetTicks() >? 0 <? 16); frameLimit = SDL_GetTicks() + 16; } @@ -110,6 +110,7 @@ engine.getInput(); if (engine.keyState[SDLK_ESCAPE]) break; + SDL_Delay(16); } } --- blobwars-1.04.orig/src/graphics.cpp +++ blobwars-1.04/src/graphics.cpp @@ -62,7 +62,7 @@ } } - while (SDL_GetTicks() < frameLimit){} + SDL_Delay(frameLimit - SDL_GetTicks() >? 0 <? 16); frameLimit = SDL_GetTicks() + 16; } --- blobwars-1.04.orig/src/game.cpp +++ blobwars-1.04/src/game.cpp @@ -227,6 +227,8 @@ graphics.delay(500); break; } + + SDL_Delay(16); } } @@ -346,7 +348,7 @@ if ((cont) || (quit)) break; - while (SDL_GetTicks() < frameLimit){} + SDL_Delay(frameLimit - SDL_GetTicks() >? 0 <? 16); frameLimit = SDL_GetTicks() + 16; } @@ -498,7 +500,7 @@ graphics.blit(panelBack, 320, 220, graphics.screen, true); graphics.blit(panel, 320, 220, graphics.screen, true); - while (SDL_GetTicks() < frameLimit){} + SDL_Delay(frameLimit - SDL_GetTicks() >? 0 <? 16); frameLimit = SDL_GetTicks() + 16; if (engine.userAccepts()) @@ -526,7 +528,7 @@ while (beamInTime > 0) { - while (SDL_GetTicks() < frameLimit){} + SDL_Delay(frameLimit - SDL_GetTicks() >? 0 <? 16); frameLimit = SDL_GetTicks() + 16; doGameStuff(); @@ -774,6 +776,8 @@ { audio.resume(); } + + SDL_Delay(16); } if ((engine.keyState[SDLK_F3]) && (engine.cheatSkipLevel)) @@ -789,7 +793,7 @@ } #endif - while (SDL_GetTicks() < (frameLimit)){} + SDL_Delay(frameLimit - SDL_GetTicks() >? 0 <? 16); frameLimit = SDL_GetTicks() + 16; if (game.missionOverReason == MIS_GAMECOMPLETE) --- blobwars-1.04.orig/src/hub.cpp +++ blobwars-1.04/src/hub.cpp @@ -785,7 +785,7 @@ graphics.blit(cursor->getCurrentFrame(), engine.getMouseX(), engine.getMouseY(), graphics.screen, true); - while (SDL_GetTicks() < frameLimit){} + SDL_Delay(frameLimit - SDL_GetTicks() >? 0 <? 16); frameLimit = SDL_GetTicks() + 16; } --- blobwars-1.04.orig/src/init.cpp +++ blobwars-1.04/src/init.cpp @@ -81,6 +81,7 @@ engine.getInput(); if (engine.keyState[SDLK_SPACE]) break; + SDL_Delay(16); } SDL_FillRect(graphics.screen, NULL, graphics.black); --- blobwars-1.04.orig/src/options.cpp +++ blobwars-1.04/src/options.cpp @@ -80,6 +80,8 @@ engine.flushInput(); done = 1; } + + SDL_Delay(16); } audio.playMenuSound(2); @@ -165,6 +167,8 @@ engine.flushInput(); done = 1; } + + SDL_Delay(16); } engine.allowJoypad = true; @@ -243,6 +247,8 @@ engine.flushInput(); done = 1; } + + SDL_Delay(16); } engine.allowJoypad = true; @@ -419,6 +425,8 @@ engine.flushInput(); done = 1; } + + SDL_Delay(16); } --- blobwars-1.04.orig/src/cutscene.cpp +++ blobwars-1.04/src/cutscene.cpp @@ -199,6 +199,8 @@ break; } } + + SDL_Delay(16); } SDL_FillRect(graphics.screen, NULL, graphics.black);