Browse Source

...goto...Peter, how could you...argh\!

feature/2015
Christian Kroll 16 years ago
parent
commit
b832adc6ce
  1. 113
      menu/menu.c

113
menu/menu.c

@ -37,75 +37,75 @@ extern game_descriptor_t _game_descriptors_end__[];
void menu() void menu()
{ {
// don't let WAIT() query fire button to prevent endless circular jumps if (MENU_ITEM_MAX != 0)
waitForFire = 0;
clear_screen(0);
// wait as long the fire button is pressed to prevent unwanted selections
while (JOYISFIRE)
{ {
wait(MENU_POLL_INTERVAL); // don't let WAIT() query fire button to prevent endless circular jumps
} waitForFire = 0;
if(MENU_ITEM_MAX == 0) goto end; clear_screen(0);
// set initial menu item // wait as long as "fire" is pressed to prevent unwanted selections
static uint8_t miSelection = 0; while (JOYISFIRE)
// scroll in currently selected menu item {
menu_animate(MENU_PREVITEM(miSelection), MENU_DIRECTION_LEFT); wait(MENU_POLL_INTERVAL);
}
uint16_t nMenuIterations= MENU_TIMEOUT_ITERATIONS; // set initial menu item
static uint8_t miSelection = 0;
// scroll in currently selected menu item
menu_animate(MENU_PREVITEM(miSelection), MENU_DIRECTION_LEFT);
while (1) uint16_t nMenuIterations= MENU_TIMEOUT_ITERATIONS;
{
// the user has made her/his choice while (1)
if (JOYISFIRE)
{ {
// prevent unwanted selections // the user has made her/his choice
while (JOYISFIRE) if (JOYISFIRE)
{ {
wait(MENU_POLL_INTERVAL); // prevent unwanted selections
} while (JOYISFIRE)
// work against the chatter effects of dump joysticks {
wait(MENU_WAIT_CHATTER); wait(MENU_POLL_INTERVAL);
}
// work against the chatter effects of dump joysticks
wait(MENU_WAIT_CHATTER);
// call corresponding function // call corresponding function
_game_descriptors_start__[miSelection].run(); _game_descriptors_start__[miSelection].run();
break; break;
} }
// change selected item and do some scrolling // change selected item and do some scrolling
else if (JOYISRIGHT) else if (JOYISRIGHT)
{ {
menu_animate(miSelection, MENU_DIRECTION_LEFT); menu_animate(miSelection, MENU_DIRECTION_LEFT);
miSelection = MENU_NEXTITEM(miSelection); miSelection = MENU_NEXTITEM(miSelection);
nMenuIterations = MENU_TIMEOUT_ITERATIONS; nMenuIterations = MENU_TIMEOUT_ITERATIONS;
} }
else if (JOYISLEFT) else if (JOYISLEFT)
{ {
menu_animate(miSelection, MENU_DIRECTION_RIGHT); menu_animate(miSelection, MENU_DIRECTION_RIGHT);
miSelection = MENU_PREVITEM(miSelection); miSelection = MENU_PREVITEM(miSelection);
nMenuIterations = MENU_TIMEOUT_ITERATIONS; nMenuIterations = MENU_TIMEOUT_ITERATIONS;
} }
// exit menu // exit menu
else if (JOYISUP) else if (JOYISUP)
{ {
break;
}
// return if timeout is reached
else
{
wait(MENU_POLL_INTERVAL);
if (--nMenuIterations == 0)
break; break;
}
// return if timeout is reached
else
{
wait(MENU_POLL_INTERVAL);
if (--nMenuIterations == 0)
break;
}
} }
}
end: waitForFire = 1;
waitForFire = 1; }
return; return;
} }
@ -116,7 +116,8 @@ uint8_t menu_getIconPixel(uint8_t item, int8_t x, int8_t y)
if (x < MENU_WIDTH_ICON) if (x < MENU_WIDTH_ICON)
{ {
// return pixel // return pixel
return (0x80 >> x) & pgm_read_word(&_game_descriptors_start__[item].icon[y]); return (0x80 >> x) &
pgm_read_word(&_game_descriptors_start__[item].icon[y]);
} }
else else
{ {

Loading…
Cancel
Save