1 /*
2 SCREENLIB: A framebuffer library based on the SDL library
3 Copyright (C) 1997 Sam Lantinga
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 5635-34 Springhouse Dr.
21 Pleasanton, CA 94588 (USA)
22 slouken@devolution.com
23 */
24
25 #include "SDL.h"
26 #include "pixel.h"
27
PutPixel1(Uint8 * screen_loc,SDL_Surface * screen,Uint32 pixel)28 void PutPixel1(Uint8 *screen_loc, SDL_Surface *screen, Uint32 pixel) {
29 *((Uint8 *)screen_loc) = pixel;
30 }
PutPixel2(Uint8 * screen_loc,SDL_Surface * screen,Uint32 pixel)31 void PutPixel2(Uint8 *screen_loc, SDL_Surface *screen, Uint32 pixel) {
32 *((Uint16 *)screen_loc) = pixel;
33 }
PutPixel3(Uint8 * screen_loc,SDL_Surface * screen,Uint32 pixel)34 void PutPixel3(Uint8 *screen_loc, SDL_Surface *screen, Uint32 pixel) {
35 int shift;
36
37 /* Gack - slow, but endian correct */
38 shift = screen->format->Rshift;
39 *(screen_loc+shift/8) = pixel>>shift;
40 shift = screen->format->Gshift;
41 *(screen_loc+shift/8) = pixel>>shift;
42 shift = screen->format->Bshift;
43 *(screen_loc+shift/8) = pixel>>shift;
44 }
PutPixel4(Uint8 * screen_loc,SDL_Surface * screen,Uint32 pixel)45 void PutPixel4(Uint8 *screen_loc, SDL_Surface *screen, Uint32 pixel) {
46 *((Uint32 *)screen_loc) = pixel;
47 }
48