52 {4,203,252}, {3,181,252}, {2,158,252}, {1,136,251}, |
52 {4,203,252}, {3,181,252}, {2,158,252}, {1,136,251}, |
53 {0,111,248}, {0,82,234}, {0,63,213}, {0,50,192}, |
53 {0,111,248}, {0,82,234}, {0,63,213}, {0,50,192}, |
54 {0,39,172}, {0,28,152}, {0,17,132}, {0,7,114} |
54 {0,39,172}, {0,28,152}, {0,17,132}, {0,7,114} |
55 }; |
55 }; |
56 |
56 |
|
57 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ |
|
58 static void quit(int rc) |
|
59 { |
|
60 SDL_Quit(); |
|
61 exit(rc); |
|
62 } |
|
63 |
57 static void sdlerr(char *when) |
64 static void sdlerr(char *when) |
58 { |
65 { |
59 fprintf(stderr, "SDL error: %s: %s\n", when, SDL_GetError()); |
66 fprintf(stderr, "SDL error: %s: %s\n", when, SDL_GetError()); |
60 exit(1); |
67 quit(1); |
61 } |
68 } |
62 |
69 |
63 /* create a background surface */ |
70 /* create a background surface */ |
64 static SDL_Surface *make_bg(SDL_Surface *screen, int startcol) |
71 static SDL_Surface *make_bg(SDL_Surface *screen, int startcol) |
65 { |
72 { |
155 gamma_ramp = 1; |
160 gamma_ramp = 1; |
156 else { |
161 else { |
157 fprintf(stderr, |
162 fprintf(stderr, |
158 "usage: testpalette " |
163 "usage: testpalette " |
159 " [-hw] [-fullscreen] [-nofade] [-gamma] [-gammaramp]\n"); |
164 " [-hw] [-fullscreen] [-nofade] [-gamma] [-gammaramp]\n"); |
160 return 1; |
165 quit(1); |
161 } |
166 } |
162 } |
167 } |
163 |
168 |
164 /* Ask explicitly for 8bpp and a hardware palette */ |
169 /* Ask explicitly for 8bpp and a hardware palette */ |
165 if(!(screen = SDL_SetVideoMode(SCRW, SCRH, 8, vidflags | SDL_HWPALETTE))) { |
170 if(!(screen = SDL_SetVideoMode(SCRW, SCRH, 8, vidflags | SDL_HWPALETTE))) { |
166 fprintf(stderr, "error setting %dx%d 8bpp indexed mode: %s\n", |
171 fprintf(stderr, "error setting %dx%d 8bpp indexed mode: %s\n", |
167 SCRW, SCRH, SDL_GetError()); |
172 SCRW, SCRH, SDL_GetError()); |
168 return 1; |
173 quit(1); |
169 } |
174 } |
170 |
175 |
171 if(!(boat[0] = SDL_LoadBMP("sail.bmp"))) |
176 if(!(boat[0] = SDL_LoadBMP("sail.bmp"))) |
172 sdlerr("loading sail.bmp"); |
177 sdlerr("loading sail.bmp"); |
173 /* We've chosen magenta (#ff00ff) as colour key for the boat */ |
178 /* We've chosen magenta (#ff00ff) as colour key for the boat */ |