soc/intel/xeon_sp/util: Enhance lock_pam0123
[coreboot2.git] / payloads / libpayload / curses / PDCurses / sdl1 / sdltest.c
blob840d15a4ebe6c158d5d75be2f6eb5fac0cf36f32
1 /* Here's a simple example of combining SDL and PDCurses functionality.
2 The top portion of the window is devoted to SDL, with a four-line
3 (assuming the default 8x16 font) stdscr at the bottom.
5 $Id: sdltest.c,v 1.2 2008/07/14 04:24:52 wmcbrine Exp $
6 */
8 #include <SDL/SDL.h>
9 #include <curses.h>
10 #include <stdlib.h>
11 #include <time.h>
13 /* You could #include pdcsdl.h, or just add the relevant declarations
14 here: */
16 PDCEX SDL_Surface *pdc_screen;
17 PDCEX int pdc_yoffset;
19 int main(int argc, char **argv)
21 char inp[60];
22 int i, j, seed;
24 seed = time((time_t *)0);
25 srand(seed);
27 /* Initialize SDL */
29 if (SDL_Init(SDL_INIT_VIDEO) < 0)
30 exit(1);
32 atexit(SDL_Quit);
34 pdc_screen = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE|SDL_ANYFORMAT);
36 /* Initialize PDCurses */
38 pdc_yoffset = 416; /* 480 - 4 * 16 */
40 initscr();
41 start_color();
42 scrollok(stdscr, TRUE);
44 PDC_set_title("PDCurses for SDL");
46 /* Do some SDL stuff */
48 for (i = 640, j = 416; j; i -= 2, j -= 2)
50 SDL_Rect dest;
52 dest.x = (640 - i) / 2;
53 dest.y = (416 - j) / 2;
54 dest.w = i;
55 dest.h = j;
57 SDL_FillRect(pdc_screen, &dest,
58 SDL_MapRGB(pdc_screen->format, rand() % 256,
59 rand() % 256, rand() % 256));
62 SDL_UpdateRect(pdc_screen, 0, 0, 640, 416);
64 /* Do some curses stuff */
66 init_pair(1, COLOR_WHITE + 8, COLOR_BLUE);
67 bkgd(COLOR_PAIR(1));
69 addstr("This is a demo of ");
70 attron(A_UNDERLINE);
71 addstr("PDCurses for SDL");
72 attroff(A_UNDERLINE);
73 addstr(".\nYour comments here: ");
74 getnstr(inp, 59);
75 addstr("Press any key to exit.");
77 getch();
78 endwin();
80 return 0;