r9680 - in packages/trunk/alex4/debian: . patches

Peter De Wachter pdewacht-guest at alioth.debian.org
Thu May 7 21:43:28 UTC 2009


Author: pdewacht-guest
Date: 2009-05-07 21:43:28 +0000 (Thu, 07 May 2009)
New Revision: 9680

Added:
   packages/trunk/alex4/debian/patches/save-some-cpu-cycles.patch
Removed:
   packages/trunk/alex4/debian/patches/level-select-bug.patch
Modified:
   packages/trunk/alex4/debian/changelog
   packages/trunk/alex4/debian/patches/allegro-4.2.patch
   packages/trunk/alex4/debian/patches/series
Log:
alex4: Added save-some-cpu-cycles.patch: fixes the game's 100% CPU usage habit.
Supersedes level-select-bug.patch.


Modified: packages/trunk/alex4/debian/changelog
===================================================================
--- packages/trunk/alex4/debian/changelog	2009-05-07 04:41:47 UTC (rev 9679)
+++ packages/trunk/alex4/debian/changelog	2009-05-07 21:43:28 UTC (rev 9680)
@@ -4,11 +4,13 @@
   * Add a watch file explaining the upstream status
 
   [ Peter De Wachter ]
-  * Fixed a bug that the made level selection screen unresponsive on
-    some systems.
   * Honor the HOME environment variable. (Closes: #507950) 
+  * Applied a patch to bring down the game's CPU usage to a more reasonable
+    level. This limits the frame rate to 50Hz (the speed of the game logic).
+    This also fixes a bug that made the level selection screen unresponsive
+    on some systems.
 
- -- Peter De Wachter <pdewacht at gmail.com>  Tue, 05 May 2009 02:08:14 +0200
+ -- Peter De Wachter <pdewacht at gmail.com>  Thu, 07 May 2009 23:35:03 +0200
 
 alex4 (1.1-2) unstable; urgency=low
 

Modified: packages/trunk/alex4/debian/patches/allegro-4.2.patch
===================================================================
--- packages/trunk/alex4/debian/patches/allegro-4.2.patch	2009-05-07 04:41:47 UTC (rev 9679)
+++ packages/trunk/alex4/debian/patches/allegro-4.2.patch	2009-05-07 21:43:28 UTC (rev 9680)
@@ -1,7 +1,5 @@
-Index: alex4-1.1/src/edit.c
-===================================================================
---- alex4-1.1.orig/src/edit.c	2008-01-23 00:01:05.000000000 +0100
-+++ alex4-1.1/src/edit.c	2008-01-23 00:48:53.000000000 +0100
+--- a/src/edit.c
++++ b/src/edit.c
 @@ -69,8 +69,8 @@
  		}
  	
@@ -47,10 +45,8 @@
  	}
  
  	if (edit_mode != EDIT_MODE_STATS) {
-Index: alex4-1.1/src/hisc.c
-===================================================================
---- alex4-1.1.orig/src/hisc.c	2008-01-23 00:48:53.000000000 +0100
-+++ alex4-1.1/src/hisc.c	2008-01-23 00:48:53.000000000 +0100
+--- a/src/hisc.c
++++ b/src/hisc.c
 @@ -153,9 +153,9 @@
  
  // draws a single hisc post
@@ -64,19 +60,8 @@
  }
  
  // draws the entire table
-Index: alex4-1.1/src/main.c
-===================================================================
---- alex4-1.1.orig/src/main.c	2008-01-23 00:48:53.000000000 +0100
-+++ alex4-1.1/src/main.c	2008-01-23 00:48:53.000000000 +0100
-@@ -322,7 +322,7 @@
- 		cycle_count = 0;
- 		if (got_sound && duh_player != NULL) al_poll_duh(duh_player);
- 		i ++;
--		while(!cycle_count)	yield_timeslice();
-+		while(!cycle_count)	rest(0);
- 	}
- }
- 
+--- a/src/main.c
++++ b/src/main.c
 @@ -496,15 +496,15 @@
  
  	rectfill(bmp, 0, y, 159, y+9, 1);
@@ -149,44 +134,8 @@
  }
  
  
-@@ -1153,7 +1151,7 @@
- 		}
+@@ -1451,12 +1449,12 @@
  
- 		// let other processes play
--		yield_timeslice();
-+		rest(0);
- 
- 		// draw stuff
- 		draw_frame(swap_screen, 1);
-@@ -1195,7 +1193,7 @@
- 		}
- 
- 		// let other processes play
--		yield_timeslice();
-+		rest(0);
- 
- 		// draw stuff
- 		draw_frame(swap_screen, 1);
-@@ -1257,7 +1255,7 @@
- 		}
- 
- 		// let other processes play
--		yield_timeslice();
-+		rest(0);
- 
- 		// draw stuff
- 		draw_custom_ending(swap_screen);
-@@ -1373,7 +1371,7 @@
- 		}
- 
- 		// let other processes play
--		yield_timeslice();
-+		rest(0);
- 
- 		// draw stuff
- 		blit(swap2, swap_screen, 0, 0, 0, 0, 160, 120);
-@@ -1447,12 +1445,12 @@
- 
  	sprintf(buf, "%s %d %s", (level > min ? "<" : " "), level, (level < max ? ">" : " "));
  	clear_bitmap(stuff);
 -	textout_centre(stuff, data[THE_FONT].dat, buf, stuff->w/2 + 1, 1, 2);
@@ -202,26 +151,8 @@
  
  	if (options.one_hundred) {
  		if (game_count & 32 || game_count & 16) draw_sprite(bmp, data[SHIP100].dat, xpos, 2);
-@@ -2343,7 +2341,7 @@
- 		if (is_fire(&ctrl) || is_jump(&ctrl)) done = 1;
- 		if (keypressed()) done = 1;
- 		if (key[KEY_ESC]) done = -1;
--		yield_timeslice();
-+		rest(0);
- 	}
+@@ -2532,20 +2530,20 @@
  
- 	if (done == -1) {
-@@ -2493,7 +2491,7 @@
- 		}
- 		
- 		// let other processes play
--		yield_timeslice();
-+		rest(0);
- 
- 		// draw 
- 		frame_count ++;
-@@ -2524,20 +2522,20 @@
- 
  	y = 60;
  	x = 50;
 -	textout(bmp, data[THE_FONT].dat, start_string, x+1, y+1, 1);
@@ -249,7 +180,7 @@
  
  	draw_sprite(bmp, data[POINTER].dat, x - 25 + fixtoi(3 * fcos(itofix(tick << 2))), 44 + menu_choice * step);
  }
-@@ -2589,7 +2587,7 @@
+@@ -2597,7 +2595,7 @@
          string[i] = letters[current_letter];
  		string[i + 1] = '\0';
          blit(block, bmp, 0, 0, pos_x - 1, pos_y - 1, block->w, block->h);
@@ -258,19 +189,8 @@
  		blit_to_screen(bmp);
  
  		if (pad != NULL) {
-@@ -2775,7 +2773,7 @@
- 		}
- 
- 		// let other processes play
--		yield_timeslice();
-+		rest(0);
- 
- 		// draw 
- 		frame_count ++;
-Index: alex4-1.1/src/map.c
-===================================================================
---- alex4-1.1.orig/src/map.c	2008-01-23 00:48:53.000000000 +0100
-+++ alex4-1.1/src/map.c	2008-01-23 00:49:56.000000000 +0100
+--- a/src/map.c
++++ b/src/map.c
 @@ -280,7 +280,7 @@
  	
  	if (sm == NULL) return;
@@ -306,10 +226,8 @@
  	
  }
  
-Index: alex4-1.1/src/script.c
-===================================================================
---- alex4-1.1.orig/src/script.c	2008-01-23 00:01:05.000000000 +0100
-+++ alex4-1.1/src/script.c	2008-01-23 00:48:53.000000000 +0100
+--- a/src/script.c
++++ b/src/script.c
 @@ -89,7 +89,7 @@
  
  	// draw text
@@ -319,28 +237,8 @@
  	}
  }
  
-@@ -103,7 +103,7 @@
- 		poll_music();
- 		count ++;
- 		while(!cycle_count);
--		yield_timeslice();
-+		rest(0);
- 	}
-     if (key[KEY_ESC]) script_done = -1;
- }
-@@ -521,7 +521,7 @@
- 		}
- 
- 		// let other processes play
--		yield_timeslice();
-+		rest(0);
- 
- 		// blit buffer to swap buffer
- 		blit(buffer, swap_buffer, 0, 0, 0, 0, 160, 120);
-Index: alex4-1.1/src/scroller.c
-===================================================================
---- alex4-1.1.orig/src/scroller.c	2008-01-23 00:01:05.000000000 +0100
-+++ alex4-1.1/src/scroller.c	2008-01-23 00:50:53.000000000 +0100
+--- a/src/scroller.c
++++ b/src/scroller.c
 @@ -65,22 +65,22 @@
  	if (sc->horizontal) {
  		if (sc->offset < -sc->length) return;
@@ -371,10 +269,8 @@
  	}
  }
  
-Index: alex4-1.1/src/shooter.c
-===================================================================
---- alex4-1.1.orig/src/shooter.c	2008-01-23 00:48:53.000000000 +0100
-+++ alex4-1.1/src/shooter.c	2008-01-23 00:48:53.000000000 +0100
+--- a/src/shooter.c
++++ b/src/shooter.c
 @@ -341,7 +341,7 @@
  		if (!o->hit || o->type == SO_PLAYER_BULLET)
  			draw_sprite(bmp, s_data[o->image].dat, (int)o->x, (int)o->y);
@@ -395,12 +291,3 @@
  }
  
  
-@@ -1268,7 +1268,7 @@
- 		
- 		
- 		// let other processes play
--		yield_timeslice();
-+		rest(0);
- 		
- 		// draw 
- 		frame_count ++;

Deleted: packages/trunk/alex4/debian/patches/level-select-bug.patch
===================================================================
--- packages/trunk/alex4/debian/patches/level-select-bug.patch	2009-05-07 04:41:47 UTC (rev 9679)
+++ packages/trunk/alex4/debian/patches/level-select-bug.patch	2009-05-07 21:43:28 UTC (rev 9680)
@@ -1,12 +0,0 @@
---- a/src/main.c
-+++ b/src/main.c
-@@ -1533,6 +1533,9 @@
- 			cycle_count --;
- 		}
- 
-+		// let other processes play
-+		rest(0);
-+
- 		// draw stuff
- 		if (start_level >= 0) {
- 			draw_select_starting_level(swap_screen, start_level, 1, options.max_levels + 1);

Added: packages/trunk/alex4/debian/patches/save-some-cpu-cycles.patch
===================================================================
--- packages/trunk/alex4/debian/patches/save-some-cpu-cycles.patch	                        (rev 0)
+++ packages/trunk/alex4/debian/patches/save-some-cpu-cycles.patch	2009-05-07 21:43:28 UTC (rev 9680)
@@ -0,0 +1,253 @@
+Fix the 100% CPU usage of alex4. We can't do this properly (the game
+is written with a DOS mindset), but we can do two things easily:
+ - Put a rest() in every busy loop.
+ - Limit the frame rate to 50Hz (the speed of the game logic).
+
+For future reference, the counters used by the game:
+game_count  = increments at 50Hz
+cycle_count = increments at 50Hz, but is reset whenever the game feels like it
+frame_count = number of frames rendered, reset every second
+logic_count = number of game loops processed, reset every second
+
+--- a/src/main.c
++++ b/src/main.c
+@@ -280,7 +280,7 @@
+ 		if (keypressed()) kp = 1;
+ 		if (is_fire(&ctrl) || is_jump(&ctrl)) kp = 1;
+ 		if (got_sound && dp != NULL) al_poll_duh(dp);
+-		while(!cycle_count);
++                rest(20);
+ 	}
+ }
+ 
+@@ -322,7 +322,7 @@
+ 		cycle_count = 0;
+ 		if (got_sound && duh_player != NULL) al_poll_duh(duh_player);
+ 		i ++;
+-		while(!cycle_count)	yield_timeslice();
++		while(!cycle_count)	rest(1);
+ 	}
+ }
+ 
+@@ -1127,6 +1127,10 @@
+ 
+ 	cycle_count = 0;
+ 	while(mode != 3) {
++		// Let other processes play
++		while(cycle_count == 0)
++			rest(1);
++
+ 		// do logic
+ 		while(cycle_count > 0) {
+ 			logic_count ++;
+@@ -1152,9 +1156,6 @@
+ 			cycle_count --;
+ 		}
+ 
+-		// let other processes play
+-		yield_timeslice();
+-
+ 		// draw stuff
+ 		draw_frame(swap_screen, 1);
+ 		draw_sprite(swap_screen, go, x, 35);
+@@ -1174,6 +1175,10 @@
+ 
+ 	cycle_count = 0;
+ 	while(mode != 3) {
++		// let other processes play
++		while(cycle_count == 0)
++			rest(1);
++
+ 		// do logic
+ 		while(cycle_count > 0) {
+ 			logic_count ++;
+@@ -1194,9 +1199,6 @@
+ 			cycle_count --;
+ 		}
+ 
+-		// let other processes play
+-		yield_timeslice();
+-
+ 		// draw stuff
+ 		draw_frame(swap_screen, 1);
+ 		draw_sprite(swap_screen, go, x, 35);
+@@ -1237,6 +1239,10 @@
+ 
+ 	cycle_count = 0;
+ 	while(!done) {
++		// let other processes play
++		while(cycle_count == 0)
++			rest(1);
++
+ 		// do logic
+ 		while(cycle_count > 0) {
+ 			logic_count ++;
+@@ -1256,9 +1262,6 @@
+ 			cycle_count --;
+ 		}
+ 
+-		// let other processes play
+-		yield_timeslice();
+-
+ 		// draw stuff
+ 		draw_custom_ending(swap_screen);
+ 		blit_to_screen(swap_screen);
+@@ -1334,6 +1337,10 @@
+ 	clear_keybuf();
+ 	cycle_count = 0;
+ 	while(mode != 3) {
++		// let other processes play
++		while(cycle_count == 0)
++			rest(1);
++
+ 		// do logic
+ 		while(cycle_count > 0) {
+ 			logic_count ++;
+@@ -1372,9 +1379,6 @@
+ 			cycle_count --;
+ 		}
+ 
+-		// let other processes play
+-		yield_timeslice();
+-
+ 		// draw stuff
+ 		blit(swap2, swap_screen, 0, 0, 0, 0, 160, 120);
+ 		draw_status_bar(swap_screen, 110);
+@@ -1488,6 +1492,10 @@
+ 
+ 	cycle_count = 0;
+ 	while(!done) {
++		// let other processes play
++		while(cycle_count == 0)
++			rest(1);
++
+ 		// do logic
+ 		while(cycle_count > 0) {
+ 			logic_count ++;
+@@ -2343,7 +2351,7 @@
+ 		if (is_fire(&ctrl) || is_jump(&ctrl)) done = 1;
+ 		if (keypressed()) done = 1;
+ 		if (key[KEY_ESC]) done = -1;
+-		yield_timeslice();
++		rest(20);
+ 	}
+ 
+ 	if (done == -1) {
+@@ -2369,6 +2377,9 @@
+ 	game_status = GS_OK;
+ 	cycle_count = 0;
+ 	while(game_status == GS_OK) {
++		// let other processes play
++		while(cycle_count == 0)
++			rest(1);
+ 
+ 		//  do logic
+ 		while(cycle_count > 0) {
+@@ -2492,9 +2503,6 @@
+ 			cycle_count --;
+ 		}
+ 		
+-		// let other processes play
+-		yield_timeslice();
+-
+ 		// draw 
+ 		frame_count ++;
+ 		draw_frame(swap_screen, 1);
+@@ -2658,7 +2666,7 @@
+ 
+ 		}
+ 
+-		while(!cycle_count);
++		while(!cycle_count) rest(1);
+ 
+     }
+ }
+@@ -2693,6 +2701,9 @@
+ 	clear_keybuf();
+ 	cycle_count = 0;
+ 	while(status == GS_OK) {
++		// let other processes play
++		while(cycle_count == 0)
++			rest(1);
+ 
+ 		//  do logic
+ 		while(cycle_count > 0) {
+@@ -2774,9 +2785,6 @@
+ 			cycle_count --;
+ 		}
+ 
+-		// let other processes play
+-		yield_timeslice();
+-
+ 		// draw 
+ 		frame_count ++;
+ 		draw_title(swap_screen, tick);
+@@ -3021,7 +3029,8 @@
+ 		blit_to_screen(swap_screen);
+ 		fade_in_pal(100);
+ 		cycle_count = 0;
+-		while(!key[KEY_ESC] && cycle_count < 200);
++		while(!key[KEY_ESC] && cycle_count < 200)
++			rest(50);
+ 		fade_out_pal(100);
+ 		clear(screen);
+ 	}
+--- a/src/script.c
++++ b/src/script.c
+@@ -102,8 +102,8 @@
+ 		cycle_count = 0;
+ 		poll_music();
+ 		count ++;
+-		while(!cycle_count);
+-		yield_timeslice();
++		while(!cycle_count)
++			rest(20);
+ 	}
+     if (key[KEY_ESC]) script_done = -1;
+ }
+@@ -498,6 +498,10 @@
+ 	cycle_count = 0;
+ 	while(loops && !script_done) {
+ 
++		// let other processes play
++		while(cycle_count == 0)
++			rest(1);
++
+ 		while(cycle_count > 0 && loops && !script_done) {
+ 			logic_count ++;
+ 
+@@ -520,9 +524,6 @@
+ 			cycle_count --;
+ 		}
+ 
+-		// let other processes play
+-		yield_timeslice();
+-
+ 		// blit buffer to swap buffer
+ 		blit(buffer, swap_buffer, 0, 0, 0, 0, 160, 120);
+ 		
+--- a/src/shooter.c
++++ b/src/shooter.c
+@@ -1131,7 +1131,10 @@
+ 	game_count = 0;
+ 	s_activate_sign(0, -1);
+ 	while(playing || s_sign.alive) {
+-		
++		// let other processes play
++		while(cycle_count == 0)
++			rest(1);
++
+ 		//  do logic
+ 		while(cycle_count > 0) {
+ 			logic_count ++;
+@@ -1266,10 +1269,6 @@
+ 			cycle_count --;
+ 		}
+ 		
+-		
+-		// let other processes play
+-		yield_timeslice();
+-		
+ 		// draw 
+ 		frame_count ++;
+ 		s_draw_frame(s_buffer);

Modified: packages/trunk/alex4/debian/patches/series
===================================================================
--- packages/trunk/alex4/debian/patches/series	2009-05-07 04:41:47 UTC (rev 9679)
+++ packages/trunk/alex4/debian/patches/series	2009-05-07 21:43:28 UTC (rev 9680)
@@ -1,5 +1,6 @@
-from-fedora.patch
+unix-port.patch
 dot-files-endian-clean.patch
+save-some-cpu-cycles.patch
 allegro-4.2.patch
 fsf-address.patch
-level-select-bug.patch
+display-fps.patch




More information about the Pkg-games-commits mailing list