- Fixed bug with 32bpp displays

- Modified contrast on phone image.
This commit is contained in:
Rob Pearce 2008-12-25 02:18:08 +00:00
parent 71dced84ff
commit 2eae5e0066
8 changed files with 73 additions and 40 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

3
defs.h
View File

@ -1079,4 +1079,7 @@ extern int curlevelnum;
extern char *datadir; extern char *datadir;
// pointer to drawpixel function
extern void (*drawpixel)(SDL_Surface *s, int x, int y, SDL_Color c);
#endif #endif

6
edit.c
View File

@ -687,14 +687,14 @@ int main (int argc, char **argv) {
// clear old line // clear old line
if (oldy != -1) { if (oldy != -1) {
drawline16(screen, LLISTX, oldy, EDITMAPW-LLISTX, oldy, black ); drawline(screen, LLISTX, oldy, EDITMAPW-LLISTX, oldy, black );
} }
// clear old text // clear old text
writetext(screen, textx, oldy-EDITTEXT, temps, EDITTEXT, &black); writetext(screen, textx, oldy-EDITTEXT, temps, EDITTEXT, &black);
// draw new line // draw new line
drawline16(screen, LLISTX, ypos, EDITMAPW-LLISTX, ypos, green ); drawline(screen, LLISTX, ypos, EDITMAPW-LLISTX, ypos, green );
oldy = ypos; oldy = ypos;
// draw new text // draw new text
@ -857,7 +857,7 @@ void drawsprites(void) {
// show waypoints // show waypoints
curx = s->x; cury = s->y; curx = s->x; cury = s->y;
for (i = 0; i < s->numwaypoints; i++) { for (i = 0; i < s->numwaypoints; i++) {
drawline16(screen, curx,cury,s->wayx[i],s->wayy[i], red); drawline(screen, curx,cury,s->wayx[i],s->wayy[i], red);
drawbox16(screen, s->wayx[i]-1,s->wayy[i]-1, drawbox16(screen, s->wayx[i]-1,s->wayy[i]-1,
s->wayx[i]+1,s->wayy[i]+1, &red, &red); s->wayx[i]+1,s->wayy[i]+1, &red, &red);

View File

@ -30,6 +30,9 @@ int deck[DECKSIZE];
int forcegoodcard; int forcegoodcard;
int nextforcegoodcard; int nextforcegoodcard;
// pointer to function
void (*drawpixel)(SDL_Surface *s, int x, int y, SDL_Color c);
SDL_Surface *levelbg; // level background image SDL_Surface *levelbg; // level background image
SDL_Surface *temps; // temporary surface SDL_Surface *temps; // temporary surface

26
rc.c
View File

@ -27,6 +27,8 @@
#include "shared.h" #include "shared.h"
#include "rc.h" #include "rc.h"
FPSmanager manager; FPSmanager manager;
SDL_Surface *temps; SDL_Surface *temps;
SDL_Surface *screen; SDL_Surface *screen;
@ -6786,7 +6788,7 @@ void drawnetting(sprite_t *s) {
if (s->netsticky) { if (s->netsticky) {
drawdotline16(screen,sx,s->nety,xx,yy,orange,yellow); drawdotline16(screen,sx,s->nety,xx,yy,orange,yellow);
} else { } else {
drawline16(screen,sx,s->nety,xx,yy,white); drawline(screen,sx,s->nety,xx,yy,white);
} }
// add sparkle // add sparkle
xx = s->x + s->netdir*s->netlen; xx = s->x + s->netdir*s->netlen;
@ -6795,9 +6797,9 @@ void drawnetting(sprite_t *s) {
} }
} }
//drawline16(screen,sx,s->nety,s->x + s->netdir*s->netlen,s->nety-3,white); //drawline(screen,sx,s->nety,s->x + s->netdir*s->netlen,s->nety-3,white);
//drawline16(screen,sx,s->nety,s->x + s->netdir*s->netlen,s->nety,white); //drawline(screen,sx,s->nety,s->x + s->netdir*s->netlen,s->nety,white);
//drawline16(screen,sx,s->nety,s->x + s->netdir*s->netlen,s->nety+3,white); //drawline(screen,sx,s->nety,s->x + s->netdir*s->netlen,s->nety+3,white);
} else if (s->slamming) { } else if (s->slamming) {
double dist; double dist;
int x,y; int x,y;
@ -9555,9 +9557,21 @@ void initsdl(void) {
screen = SDL_SetVideoMode(640,480,16,SDL_OPENGLBLIT|vidargs); screen = SDL_SetVideoMode(640,480,16,SDL_OPENGLBLIT|vidargs);
#else #else
//screen = SDL_SetVideoMode(640,480,16,SDL_SWSURFACE|SDL_DOUBLEBUF|vidargs); //screen = SDL_SetVideoMode(640,480,16,SDL_SWSURFACE|SDL_DOUBLEBUF|vidargs);
// Try for 16 bit mode, but SDL_ANYFORMAT means that 32 bit is acceptable.
screen = SDL_SetVideoMode(640,480,16,SDL_SWSURFACE|SDL_ANYFORMAT|vidargs); screen = SDL_SetVideoMode(640,480,16,SDL_SWSURFACE|SDL_ANYFORMAT|vidargs);
#endif #endif
// set drawpixel function based on what depth we ended up with
if (screen->format->BitsPerPixel == 32) {
drawpixel = drawpixel32;
printf("32 bit mode in use.\n");
} else {
drawpixel = drawpixel16;
printf("16 bit mode in use.\n");
}
// set title bar // set title bar
SDL_WM_SetCaption(progname, progname); SDL_WM_SetCaption(progname, progname);
@ -11063,7 +11077,7 @@ void docannoneffect(sprite_t *pp) {
// horiz lines // horiz lines
for (i = 0; i < initsize ; i++) { for (i = 0; i < initsize ; i++) {
drawline16(screen,0,yy,640,yy,white); drawline(screen,0,yy,640,yy,white);
for (s3 = sprite; s3 ; s3 = s3->next) { for (s3 = sprite; s3 ; s3 = s3->next) {
if (ismonster(s3->id) && !s3->dead) { if (ismonster(s3->id) && !s3->dead) {
if (!s3->caughtby) { if (!s3->caughtby) {
@ -11079,7 +11093,7 @@ void docannoneffect(sprite_t *pp) {
} }
// vert lines // vert lines
for (i = 0; i < initsize ; i++) { for (i = 0; i < initsize ; i++) {
drawline16(screen,xx,0,xx,480,white); drawline(screen,xx,0,xx,480,white);
for (s3 = sprite; s3 ; s3 = s3->next) { for (s3 = sprite; s3 ; s3 = s3->next) {
if (ismonster(s3->id) && !s3->dead) { if (ismonster(s3->id) && !s3->dead) {
if (!s3->caughtby) { if (!s3->caughtby) {

View File

@ -2285,11 +2285,11 @@ void drawsprite(sprite_t *s) {
// draw lines to zap position // draw lines to zap position
zapx = s->zapping->x; zapx = s->zapping->x;
zapy = s->zapping->y; zapy = s->zapping->y;
drawline16(screen, s->x, s->y - (s->img->h/2),zapx, zapy, col); drawline(screen, s->x, s->y - (s->img->h/2),zapx, zapy, col);
drawline16(screen, s->x+1, s->y - (s->img->h/2),zapx, zapy, col); drawline(screen, s->x+1, s->y - (s->img->h/2),zapx, zapy, col);
drawline16(screen, s->x-1, s->y - (s->img->h/2),zapx, zapy, col); drawline(screen, s->x-1, s->y - (s->img->h/2),zapx, zapy, col);
drawline16(screen, s->x, s->y+1 - (s->img->h/2),zapx, zapy, col); drawline(screen, s->x, s->y+1 - (s->img->h/2),zapx, zapy, col);
drawline16(screen, s->x, s->y-1 - (s->img->h/2),zapx, zapy, col); drawline(screen, s->x, s->y-1 - (s->img->h/2),zapx, zapy, col);
} else { // the thing we were zapping died! } else { // the thing we were zapping died!
s->timer4 = 0; s->timer4 = 0;
} }
@ -2315,7 +2315,7 @@ void drawsprite(sprite_t *s) {
return; return;
} }
} }
drawline16(screen,s->x,s->y - (s->img->h/2),s->x,ty*TILEH+TILEH-1,white); drawline(screen,s->x,s->y - (s->img->h/2),s->x,ty*TILEH+TILEH-1,white);
} }
@ -2426,11 +2426,11 @@ void drawsprite(sprite_t *s) {
if ((s->caughtby) && (s->caughtstate == 2)){ if ((s->caughtby) && (s->caughtstate == 2)){
// only if we're on the screen // only if we're on the screen
if ((s->y >= 0) && (s->y <= 480)) { if ((s->y >= 0) && (s->y <= 480)) {
drawline16(screen, s->x,s->y - s->img->h, drawline(screen, s->x,s->y - s->img->h,
s->caughtby->x,s->caughtby->y-(s->caughtby->img->h/2), white); s->caughtby->x,s->caughtby->y-(s->caughtby->img->h/2), white);
drawline16(screen, s->x,s->y - (s->img->h/2), drawline(screen, s->x,s->y - (s->img->h/2),
s->caughtby->x,s->caughtby->y-(s->caughtby->img->h/2), white); s->caughtby->x,s->caughtby->y-(s->caughtby->img->h/2), white);
drawline16(screen, s->x,s->y, drawline(screen, s->x,s->y,
s->caughtby->x,s->caughtby->y-(s->caughtby->img->h/2), white); s->caughtby->x,s->caughtby->y-(s->caughtby->img->h/2), white);
} }
} }
@ -2782,23 +2782,38 @@ inline void drawpixel16(SDL_Surface *screen, int x, int y, SDL_Color c)
#else #else
inline void drawpixel16(SDL_Surface *screen, int x, int y, SDL_Color c) inline void drawpixel16(SDL_Surface *s, int x, int y, SDL_Color c)
{ {
Uint16 *bufp; Uint16 *bufp;
/* check x/y */ // check x/y
if (x >= screen->w) return; if (x >= s->w) return;
if (y >= screen->h) return; if (y >= s->h) return;
if (x < 0) return; if (x < 0) return;
if (y < 0) return; if (y < 0) return;
bufp = (Uint16 *)screen->pixels + (y*screen->pitch / 2) + x; bufp = (Uint16 *)s->pixels + (y*s->pitch / 2) + x;
*bufp = SDL_MapRGB(screen->format, c.r, c.g, c.b); *bufp = SDL_MapRGB(s->format, c.r, c.g, c.b);
} }
#endif #endif
void drawline16(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color c) { inline void drawpixel32(SDL_Surface *s, int x, int y, SDL_Color c)
{
Uint32 *bufp;
/* check x/y */
if (x >= s->w) return;
if (y >= s->h) return;
if (x < 0) return;
if (y < 0) return;
bufp = (Uint32 *)s->pixels + (y*s->pitch / 4) + x;
*bufp = SDL_MapRGB(s->format, c.r, c.g, c.b);
}
void drawline(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color c) {
int deltax, deltay; int deltax, deltay;
int numpixels; int numpixels;
int d; int d;
@ -2809,8 +2824,6 @@ void drawline16(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color c
int maskcount = 0; int maskcount = 0;
int maskindex = 0; int maskindex = 0;
deltax = (x2 - x1); deltax = (x2 - x1);
if (deltax < 0) deltax = -deltax; if (deltax < 0) deltax = -deltax;
deltay = (y2 - y1); deltay = (y2 - y1);
@ -2851,7 +2864,7 @@ void drawline16(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color c
maskindex = 0; maskindex = 0;
for (i = 0; i < numpixels; i++) { for (i = 0; i < numpixels; i++) {
drawpixel16(screen,x,y,c); drawpixel(screen,x,y,c);
@ -2922,9 +2935,9 @@ void drawdotline16(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Colo
for (i = 0; i < numpixels; i++) { for (i = 0; i < numpixels; i++) {
if (i % 2 == 0) { if (i % 2 == 0) {
drawpixel16(screen,x,y,c); drawpixel(screen,x,y,c);
} else { } else {
drawpixel16(screen,x,y,c2); drawpixel(screen,x,y,c2);
} }
@ -2948,14 +2961,14 @@ void drawbox16(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color *c
if (((x2 - x1) >= 2) && ((y2 - y1) >= 2)) { if (((x2 - x1) >= 2) && ((y2 - y1) >= 2)) {
int y; int y;
for (y = (y1+1) ; y <= (y2-1); y++) { for (y = (y1+1) ; y <= (y2-1); y++) {
drawline16(screen, x1+1, y, x2-1,y,*fc); drawline(screen, x1+1, y, x2-1,y,*fc);
} }
} }
} }
drawline16(screen,x1,y1,x2,y1,*c); drawline(screen,x1,y1,x2,y1,*c);
drawline16(screen,x1,y1,x1,y2,*c); drawline(screen,x1,y1,x1,y2,*c);
drawline16(screen,x1,y2,x2,y2,*c); drawline(screen,x1,y2,x2,y2,*c);
drawline16(screen,x2,y1,x2,y2,*c); drawline(screen,x2,y1,x2,y2,*c);
} }
@ -4236,10 +4249,10 @@ void drawplayer(sprite_t *s, SDL_Rect *where) {
// littlebox // littlebox
drawbox16(screen, s->x-1,s->y-1,s->x+1,s->y+1, ccol, NULL); drawbox16(screen, s->x-1,s->y-1,s->x+1,s->y+1, ccol, NULL);
// lines // lines
drawline16(screen, s->x, 0, s->x, s->y-(TILEH/2), *ccol); // top drawline(screen, s->x, 0, s->x, s->y-(TILEH/2), *ccol); // top
drawline16(screen, s->x, s->y+(TILEH/2), s->x, 480-1, *ccol); // bottom drawline(screen, s->x, s->y+(TILEH/2), s->x, 480-1, *ccol); // bottom
drawline16(screen, 0, s->y, s->x-(TILEW/2), s->y, *ccol); // left drawline(screen, 0, s->y, s->x-(TILEW/2), s->y, *ccol); // left
drawline16(screen, s->x+(TILEW/2), s->y, 640-1, s->y, *ccol); // right drawline(screen, s->x+(TILEW/2), s->y, 640-1, s->y, *ccol); // right
return; return;
} }

View File

@ -27,7 +27,7 @@ int flowertogem(int id);
inline void drawpixel16(SDL_Surface *screen, int x, int y, SDL_Color c); inline void drawpixel16(SDL_Surface *screen, int x, int y, SDL_Color c);
inline void drawpixel32(SDL_Surface *screen, int x, int y, SDL_Color c); inline void drawpixel32(SDL_Surface *screen, int x, int y, SDL_Color c);
inline void drawbox16(SDL_Surface *screen, int x1,int y1,int x2,int y2,SDL_Color *c,SDL_Color *fc); inline void drawbox16(SDL_Surface *screen, int x1,int y1,int x2,int y2,SDL_Color *c,SDL_Color *fc);
void drawline16(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color c); void drawline(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color c);
void drawdotline16(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color c, SDL_Color c2); void drawdotline16(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color c, SDL_Color c2);
int getcolor(SDL_Surface *dest, int x, int y, SDL_Color *col); int getcolor(SDL_Surface *dest, int x, int y, SDL_Color *col);
/* /*

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB