#include #include #include #include #include #include #include #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; 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) { //char eop = 0; 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': 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); break; case 'l': 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); break; } } return 0; }