void DRAWALL(unsigned char x, unsigned char y) { FastCopyScreen(virtual_dark, Hiddend); FastCopyScreen(virtual_light, Hiddenl); GraySprite8_MASK(x, y, 8, chipl, chipd, chipmask, chipmask, Hiddenl, Hiddend); GrayDBufToggleSync(); // switches two sets of planes }
static inline void DRAW_MENU(int choice) { //unsigned char loop; unsigned char y = 31 + 13 * choice + 2 * (choice > 1); FastCopyScreen(virtual_light, Hiddenl); FastCopyScreen(virtual_dark, Hiddend); //memset(Hiddend, 0, LCD_SIZE); //GraySpriteX8_OR(48, 16, 67, menul, menud, 8, Hiddenl, //Hiddend); InvertGrayRect2B(48, y, 112, y + 12, Hiddenl, Hiddend); //for(loop = 0; loop < 12; loop++) // LINE(48, y + loop, 112, y + loop, BLACK, A_XOR); GrayDBufToggleSync(); // switches two sets of planes }
static inline int MENU(void) { int STATUS = RUNNING, choice = 0; FastCopyScreen(Actived, virtual_light); memset(virtual_dark, 0, LCD_SIZE); GraySpriteX8_OR(48, 16, 67, menul, menud, 8, virtual_light, virtual_dark); char buf[2] = { 0, 0 }; do // Loops until you choose new game, exit, or press Home { do { DRAW_MENU(choice); /*if (_keytest (RR_UP) && choice > 0) { choice--; } if (_keytest (RR_DOWN) && choice < 3) { choice++; }*/ if (_keytest (RR_DOWN)) { if (buf[0] == FALSE) { buf[0] = TRUE; if (++choice > 3) choice = 0; } } else buf[0] = FALSE; if (_keytest (RR_UP)) { if (buf[1] == FALSE) { buf[1] = TRUE; if (--choice < 0) choice = 3; } } else buf[1] = FALSE; if (_keytest (RR_2ND) || _keytest (RR_ENTER)) { STATUS = DROP; while(_keytest (RR_2ND) || _keytest (RR_ENTER)); } if (_keytest (RR_ESC)) STATUS = EXIT; } while (STATUS == RUNNING); if (STATUS == DROP && choice != 3) { STATUS = RUNNING; switch(choice) { case 1: if (DISPLAY_SCORES() == QUIT) return QUIT; break; case 2: info(); break; } } if (STATUS == EXIT || choice == 3) return -1; } while(choice); return STATUS; }
// entry point void _main(void) { // some variables for the main loop unsigned int lasttick = 0; void *keyqueue = kbd_queue(); unsigned short key; // initiate all the stuff init(); // start at the menu switchgs(GS_MENU); // main loop while (gs != GS_NONE) { // run at 20 fps if (FiftyMsecTick != lasttick) { // Check for keypresses if (!OSdequeue(&key, keyqueue)) { if (key == KEY_ON) off(); else if (key == KEY_QUIT) switchgs(GS_NONE); else { switch (gs) { case GS_MENU: if (key == KEY_ENTER) switchgs(GS_GAME); else if (key == KEY_ESC) switchgs(GS_NONE); break; case GS_GAME: if (key == KEY_ENTER) game_flap(); else if (key == KEY_ESC) switchgs(GS_MENU); break; case GS_GAMEOVER: if (key == KEY_ENTER) switchgs(GS_GAME); else if (key == KEY_ESC) switchgs(GS_MENU); break; default: break; } } } // draw to the buffers GrayClearScreen2B(lightbuffer, darkbuffer); switch (gs) { case GS_MENU: menu_update(); menu_draw(); break; case GS_GAME: game_update(); game_draw(); break; case GS_GAMEOVER: gameover_update(); game_draw(); gameover_draw(); break; default: break; } // flip the buffers FastCopyScreen(darkbuffer, darkplane); FastCopyScreen(lightbuffer, lightplane); lasttick = FiftyMsecTick; framecounter++; } } // important! deinit(); }