Okay well for what it's worth, here's my int main() and globals. This should get your started...



int fd;
int rc=-99;
gdImagePtr image, teenyFontImage, leftArrowImage, rightArrowImage;
unsigned char screenbuf[EMPEG_SCREEN_ROWS][EMPEG_SCREEN_COLS/2]= {0,};
int off, dim, med, bri;
CATEGORY categories[ MAXCATEGORIES ];
int g_iNumCategories=0;
int g_iNumSelectedCategories=0;
int g_iCatNum=0;
int g_iDiffMin = 0;
int g_iDiffMax = 100;
int g_iGameMode=0;
int g_iScore=0;
int g_iRight=0;
int g_iWrong=0;
question_t theQuestion;

menu_t g_menuMain, g_menuOptions, g_menuGameMode, g_menuOkCancel, g_menuNext, g_menuNextDone;

/*---------------------------------------------------------------------------
int main()
---------------------------------------------------------------------------*/
int main() {

// declarations
int looping=1;
int menu_index;
char *menulabels[] = {"EmpTrivia", NULL};
pthread_t theTimerThread;
pthread_attr_t attr;
unsigned long data=0, buttons[6] = {6,
IR_KNOB_PRESSED,
IR_KNOB_RELEASED,
IR_KNOB_LEFT,
IR_KNOB_RIGHT,
IR_TOP_BUTTON_PRESSED};

hijack_geom_t geom = {0,7,0,EMPEG_SCREEN_COLS-2}, fullscreen = {0,EMPEG_SCREEN_ROWS-1,0,EMPEG_SCREEN_COLS-1};

int xMenu;
int i;
int iChoice=0, iChoice2=0, iCategory=0;
unsigned int charS[5][3] = { { 1, 3, 3}, { 3, 1, 0}, { 1, 3, 1}, {0, 1, 3}, {3, 3, 1} };
FILE* imgfd;
FILE* fdConfig;
FILE* fdTriv;

int iNumCategories = -1;
int iCatNum = 0;
int iQuesNum = -1;



// create the main image object
if(!(image = gdImageCreate(EMPEG_SCREEN_COLS, EMPEG_SCREEN_ROWS))) {
fprintf(stderr, "Cannot create GD image\n");
exit(1);
}
// need to allocate colors for GD library
off = gdImageColorAllocate(image, 0, 0, 0);
dim = gdImageColorAllocate(image, 64, 64, 64);
med = gdImageColorAllocate(image, 128, 128, 128);
bri = gdImageColorAllocate(image, 255, 255, 255);

// main menu
strcpy(g_menuMain.szName, "Main");
g_menuMain.iNumChoices = 4;
strcpy(g_menuMain.aszMenuChoices[0], "Play");
strcpy(g_menuMain.aszMenuChoices[1], "Options");
// strcpy(g_menuMain.aszMenuChoices[2], "Fix");
strcpy(g_menuMain.aszMenuChoices[2], "About");
strcpy(g_menuMain.aszMenuChoices[3], "Quit");

strcpy(g_menuOptions.szName, "Options");
g_menuOptions.iNumChoices = 4;
strcpy(g_menuOptions.aszMenuChoices[0], "Game");
strcpy(g_menuOptions.aszMenuChoices[1], "Categories");
strcpy(g_menuOptions.aszMenuChoices[2], "Level");
strcpy(g_menuOptions.aszMenuChoices[3], "Back");

strcpy(g_menuGameMode.szName, "Game Mode");
g_menuGameMode.iNumChoices = 3;
strcpy(g_menuGameMode.aszMenuChoices[0], "Normal");
strcpy(g_menuGameMode.aszMenuChoices[1], "Survival");
strcpy(g_menuGameMode.aszMenuChoices[2], "Back");

strcpy(g_menuOkCancel.szName, "");
g_menuOkCancel.iNumChoices = 2;
strcpy(g_menuOkCancel.aszMenuChoices[0], "OK");
strcpy(g_menuOkCancel.aszMenuChoices[1], "Cancel");

strcpy(g_menuNext.szName, "");
g_menuNext.iNumChoices = 1;
strcpy(g_menuNext.aszMenuChoices[0], "Next");

strcpy(g_menuNextDone.szName, "");
g_menuNextDone.iNumChoices = 2;
strcpy(g_menuNextDone.aszMenuChoices[0], "Next");
strcpy(g_menuNextDone.aszMenuChoices[1], "Done");



/*
gdImageFill(image, 100, 16, dim);
gdImageArc(image, 100, 16, 32, 32, 0, 360, bri);
gdImageString(image, gdFontGiant, 3, 0, "[censored] you!", bri);
*/

fd = open("/dev/display", O_RDWR);

imgfd = fopen("ascii_small.gd", "r");

if ( imgfd == NULL) {
fprintf(stderr, "cannot open font file\n");
exit(-1);
}

// rc = ioctl(fd,EMPEG_HIJACK_SETGEOM, &geom);
// printf("geom set\n");
// checkRC("setgeom()\n", rc);

teenyFontImage = gdImageCreateFromGd(imgfd);

fclose(imgfd);

imgfd = fopen("leftarrow.gd", "r");
if ( imgfd == NULL) {
fprintf(stderr, "cannot open font file\n");
exit(-1);
}
leftArrowImage = gdImageCreateFromGd(imgfd);

fclose(imgfd);

imgfd = fopen("rightarrow.gd", "r");
if ( imgfd == NULL) {
fprintf(stderr, "cannot open font file\n");
exit(-1);
}
rightArrowImage = gdImageCreateFromGd(imgfd);

fclose(imgfd);



srand( time(NULL)) ;
loadCats();

/*
rc = pthread_attr_init(&attr);
checkRC("pthread_attr_init()\n", rc);

rc = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
checkRC("setdetachstate()\n", rc);

rc = pthread_create(&theTimerThread, &attr, timerThread, NULL);
checkRC("pthread_create()\n", rc);

rc = pthread_join(theTimerThread, NULL);
*/

// -======================================================================-
// main program loop
// -======================================================================-
top:
while (1) {
looping = 1;

rc = ioctl(fd, EMPEG_HIJACK_WAITMENU, &menulabels);
if (rc < 0) {
fprintf(stderr, "rc waitmenu: %d", rc);
}
else {
menu_index = rc;
}

rc = ioctl(fd,EMPEG_HIJACK_BINDBUTTONS, buttons);
if ( rc != 0) {
fprintf(stderr, "rc bind: %d", rc);
}

while (looping) {
clearScreen();
iChoice = chooseMenu(g_menuMain, 1, 0, iChoice);
switch (iChoice) {
case 0:
play();
break;
case 1:
clearScreen();
optionsMenu();
break;
case 2:
//fixAscii();
showAbout();
//askQuestion( 0, 40 );
break;
case 3:
clearScreen();
looping = 0;
goto top;
break;
case 4:
looping=0;
break;
default:
break;
}
}
}}

_________________________
- Tony C
my empeg stuff