All pastes #59073 Raw Edit

Anonymous

public c v1 · immutable
#59073 ·published 2006-05-26 17:17 UTC
rendered paste body
#include <stdlib.h>#include <unistd.h>#include <stdio.h>#include <linux/kd.h>#include <sys/ioctl.h>#include <sys/fcntl.h>#include <termios.h>#include "hotdog.h"uint32 *screen;static uint32 WIDTH, HEIGHT;struct termio savetty, settty;int n = 0, cur_item = 2;char ch, input = 0;fd_set rd;struct timeval tv;hd_object *obj[10];hd_engine *engine;int lskip, rskip, skip = 0;void create_selector(int i) {   obj[1]    = HD_PNG_Create("/img/black/sel.png");   obj[1]->x = obj[i]->x;   obj[1]->y = obj[i]->y;   obj[1]->w = 72;   obj[1]->h = 86;}static void update(hd_engine *e, int x, int y, int w, int h){	HD_LCD_Update (e->screen.framebuffer, 0, 0, WIDTH, HEIGHT);}void move_sel(int i) //Moves Selection to an icon!{  HD_Destroy(obj[1]);	create_selector(i);  int c = 0;  for (c = 0; c <= 6; c++) {	 HD_Register(engine, obj[c]);  }}void KB_Init(void){	int flags = fcntl(0, F_GETFL, 0);	int fd = open("/dev/console", O_NONBLOCK);	if (fd < 0)	{		printf("attention: console still active!\n");		sleep(20);		/* not _deadly_ if we can't set graphics mode */		return;	}	ioctl(fd, KDSETMODE, KD_GRAPHICS);	close(fd);    fcntl(0, F_SETFL, flags | O_NONBLOCK);    ioctl(0, TCGETA, &savetty);    ioctl(0, TCGETA, &settty);    settty.c_lflag &= ~ICANON;    settty.c_lflag &= ~ECHO;    ioctl(0, TCSETAF, &settty);}int main(int argc, char **argv){	HD_LCD_Init();	KB_Init();	HD_LCD_GetInfo(0, &WIDTH, &HEIGHT, 0);	screen = malloc(WIDTH * HEIGHT * 2 * sizeof(uint32));	engine = HD_Initialize(WIDTH, HEIGHT, 16, screen, update);        obj[0]    = HD_PNG_Create ("/img/black/bg.png");        obj[0]->x = 0;        obj[0]->y = 0;        obj[0]->w = 320;        obj[0]->h = 240;                create_selector(2);                obj[2]    = HD_PNG_Create ("/img/black/scummvm.png");        obj[2]->x = 20;        obj[2]->y = 60;        obj[2]->w = 72;        obj[2]->h = 86;                obj[3]    = HD_PNG_Create ("/img/black/idoom.png");        obj[3]->x = WIDTH/2-32;        obj[3]->y = 35;        obj[3]->w = 72;        obj[3]->h = 86;                obj[4]    = HD_PNG_Create ("/img/black/iboy.png");        obj[4]->x = WIDTH-84;        obj[4]->y = 60;        obj[4]->w = 72;        obj[4]->h = 86;                obj[5]    = HD_PNG_Create ("/img/black/quit.png");        obj[5]->x = 180;        obj[5]->y = 140;        obj[5]->w = 72;        obj[5]->h = 86;                obj[6]    = HD_PNG_Create ("/img/black/mame.png");        obj[6]->x = 80;        obj[6]->y = 140;        obj[6]->w = 72;        obj[6]->h = 86;	int c = 0;	for (c = 0; c <= 6; c++) {	 HD_Register(engine, obj[c]);	}		//while (!eop) {	HD_Render(engine);	//}		while( input == 0 ) {				switch(getc(stdin)) {				case 'r':					if(rskip == 's')					{						switch(cur_item) {							case 2:								cur_item = 3;								break;							case 3:								cur_item = 4;								break;							case 4:								cur_item = 5;								break;							case 5:								cur_item = 6;								break;							case 6:								cur_item = 2;								break;							}							move_sel(cur_item);							HD_Render(engine);					}					else if(rskip == 10)					{ rskip = 's'; }					else					{ rskip++; }					break;				case 'l':					if(lskip == 's')					{						switch(cur_item) {							case 2:								cur_item = 6;								break;							case 6:								cur_item = 5;								break;							case 5:								cur_item = 4;								break;							case 4:								cur_item = 3;								break;							case 3:								cur_item = 2;								break;						}						move_sel(cur_item);							HD_Render(engine);					}					else if(lskip == 10)					{ lskip = 's'; }					else					{ lskip++; }					break;                          case -1:                                        if(skip == 10)                                        {                                                lskip = 0;                                                rskip = 0;                                                skip = 0;                                        }                                        else                                        { skip++; }                                        break;				}		}	return 0;}