1 /*
2 * IceBreaker
3 * Copyright (c) 2000-2002 Matthew Miller <mattdm@mattdm.org>
4 *
5 * <http://www.mattdm.org/icebreaker/>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc., 59
19 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22 
23 
24 #include <SDL.h>
25 #include <stdlib.h>
26 #include "icebreaker.h"
27 #include "globals.h"
28 #include "laundry.h"
29 #include "options.h"
30 #include "fullscreen.h"
31 
32 static SDL_Rect laundrylist[MAXDIRTY];
33 static int laundrycount;
34 
initlaundry()35 void initlaundry()
36 {
37 	laundrycount=0;
38 }
39 
40 
soil(SDL_Rect r)41 void soil(SDL_Rect r)
42 { // makes stuff dirty, of course.
43 	if (laundrycount<MAXDIRTY) // it's good to have this check here, but
44 	{                          // since this is the most-used function in
45 	                           // the whole program, it might be worth removing
46 	                           // for production builds...
47 		laundrylist[laundrycount] = r;
48 		laundrycount++;
49 	}
50 	else
51 	{
52 		// fix -- we ought to at least fail gracefully.
53 		// (clean whole screen, laundrylist)
54 		// might be worth dynamically calculating the point at which
55 		// updating everything is more efficient than updating many
56 		// rects.
57 		fprintf(stderr, "Too much dirty laundry!\n");
58 		exit(1);
59 	}
60 }
61 
clean()62 void clean()
63 {
64 	int i;
65 	if (gameflags.isfullscreen)
66 	{
67 		for( i = 0; i < laundrycount; i++)
68 		{ // fix -- sucks to have to do a loop here, but not
69 		  // easy to avoid.
70 			laundrylist[i].x += (FULLWIDTH - WIDTH) / 2;
71 			laundrylist[i].y += FULLTOPMARGIN;
72 		}
73 		SDL_UpdateRects(fullscreen, laundrycount, laundrylist);
74 	}
75 	else
76 	{
77 		SDL_UpdateRects(screen, laundrycount, laundrylist);
78 	}
79 	laundrycount=0;
80 }
81 
updateall()82 void updateall()
83 {
84 	// FIX -- anything that needs to call this should be fixed to
85 	// use the laundry list properly. then we can remove this
86 	// function completely.
87 
88 	if (gameflags.isfullscreen)
89 		SDL_UpdateRect(fullscreen,0,0,0,0);
90 	else
91 		SDL_UpdateRect(screen,0,0,0,0);
92 
93 	laundrycount=0;
94 }
95