rendered paste bodyint video::vid_putpixel(int x, int y, Uint8 R, Uint8 G, Uint8 B) { fprintf(stdout, "%x - %x\n", &screen->format, &SDL_MapRGB); Uint32 color = SDL_MapRGB(screen->format, R, G, B); if(DEBUG) fprintf(stderr, "vid_putpixel(%d,%d,%d,%d,%d)>", x, y, R, G, B); if((x >= 0) && (x < screen->w) && (y >= 0) && (y < screen->h)) { if(DEBUG) fprintf(stderr, "h "); switch (screen->format->BytesPerPixel) { case 1: { // Assuming 8-bpp Uint8 *bufp; bufp = (Uint8 *)screen->pixels + y*screen->pitch + x; *bufp = color; } break; case 2: { // Probably 15-bpp or 16-bpp Uint16 *bufp; bufp = (Uint16 *)screen->pixels + y*screen->pitch/2 + x; *bufp = color; } break; case 3: { // Slow 24-bpp mode, usually not used Uint8 *bufp; bufp = (Uint8 *)screen->pixels + y*screen->pitch + x * 3; if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { bufp[0] = color; bufp[1] = color >> 8; bufp[2] = color >> 16; } else { bufp[2] = color; bufp[1] = color >> 8; bufp[0] = color >> 16; } } break; case 4: // Probably 32-bpp Uint32 *bufp; bufp = (Uint32 *)screen->pixels + y*screen->pitch/4 + x; *bufp = color; break; default: // Something really fucked up happened... return -1; break; } } else { if(DEBUG) fprintf(stderr, "i "); } return 0;}