#include "../include/menus.h" #include #include #include "../parameters.h" #include #include extern bopti_image_t mainscreen; extern bopti_image_t africa1, desert1, finland1, plains1, usa1; extern bopti_image_t flag, linear, circular; extern font_t autofont, autofontsmall, speedfont; extern bool record; extern bool screenshot; bool doneTitle = false; bool doneMainMenu = false; uint8_t MainMenuSelection=0; bool doneMenuCircuit = false; int8_t CircuitSelection=0; bool doneMenuCredit = false; bool doneOptions = false; uint8_t OptionsSelection=0; bool doneGameOptions = false; uint8_t GameOptionsSelection=0; bool donePauseQuit = false; uint8_t PauseQuitSelection=0; extern bool BDrawDeco; extern bool BDrawClds; extern bool BDrawCars; extern bool BDrawFPS; extern bool BDrawBack; extern bool exitToOS; extern bool stop; extern bool SkipTime; extern uint8_t DiffLevel; extern uint8_t CarsNumb; extern char PlayerName[3]; bool nameCurrentlyWritten = false; uint8_t selectedChar=0; void drawStartTitle( void ) { uint16_t pulse=0; doneTitle = false; while (!doneTitle) { dclear( C_BLACK ); dsubimage( 0, 32, &mainscreen, 0, 32, 396, 160, DIMAGE_NONE); dfont(&autofont); dprint_opt(198, 2, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "OUTRUN FOR FX-CG50" ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, "PRESS EXE TO START" ); // CODE HERE TO PRINT WELCOME MENU dupdate(); pulse++; getInputStartTitle(); #if IS_FXLIB==1 if (screenshot && usb_is_open()) { usb_fxlink_screenshot(false); screenshot = false; } if(record && usb_is_open()) { usb_fxlink_videocapture(false); } #endif } } void getInputStartTitle( void ) { int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS; int timeout = 1; while(1) { key_event_t ev = getkey_opt(opt, &timeout); if(ev.type == KEYEV_NONE) return; int key = ev.key; if (key==KEY_EXE) doneTitle = true; #if IS_FXLIB==1 if(keydown(KEY_F5)) screenshot = true; if(keydown(KEY_F6)) record = !record; #endif // IS_FXLIB } } int drawMainMenu( void ) { uint16_t pulse=0; doneMainMenu = false; MainMenuSelection=0; while (!doneMainMenu) { dclear(0x0000); dimage( 0, 0, &mainscreen); dfont(&autofont); dprint_opt(94, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "ARCADE GAME" ); if (MainMenuSelection!=0) dprint_opt(92, 20, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "ARCADE GAME" ); else dprint_opt(92, 20, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "ARCADE GAME" ); dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "TIME ATTACK" ); if (MainMenuSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "TIME ATTACK" ); else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "TIME ATTACK" ); dprint_opt(94, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "GAME OPTIONS" ); if (MainMenuSelection!=2) dprint_opt(92, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "GAME OPTIONS" ); else dprint_opt(92, 80, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "GAME OPTIONS" ); dprint_opt(94, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "VISUAL OPTIONS" ); if (MainMenuSelection!=3) dprint_opt(92, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "VISUAL OPTIONS" ); else dprint_opt(92, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "VISUAL OPTIONS" ); dprint_opt(94, 142, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CREDITS" ); if (MainMenuSelection!=4) dprint_opt(92, 140, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CREDITS" ); else dprint_opt(92, 140, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CREDITS" ); dprint_opt(94, 172, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "QUIT TO OS" ); if (MainMenuSelection!=5) dprint_opt(92, 170, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "QUIT TO OS" ); else dprint_opt(92, 170, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "QUIT TO OS" ); dimage( 2, 10+30*MainMenuSelection, &flag ); // CODE HERE TO PRINT WELCOME MENU dupdate(); pulse++; getInputMainMenu(); #if IS_FXLIB==1 if (screenshot && usb_is_open()) { usb_fxlink_screenshot(false); screenshot = false; } if(record && usb_is_open()) { usb_fxlink_videocapture(false); } #endif } return MainMenuSelection; } void getInputMainMenu( void ) { int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS; int timeout = 1; while(1) { key_event_t ev = getkey_opt(opt, &timeout); if(ev.type == KEYEV_NONE) return; int key = ev.key; if (key==KEY_EXE) doneMainMenu = true; if (key==KEY_UP) { if (MainMenuSelection==0) MainMenuSelection=5; else MainMenuSelection--; } if (key==KEY_DOWN) { if (MainMenuSelection==5) MainMenuSelection=0; else MainMenuSelection++; } #if IS_FXLIB==1 if(keydown(KEY_F5)) screenshot = true; if(keydown(KEY_F6)) record = !record; #endif // IS_FXLIB } } void drawRectangle( uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color, uint8_t thick ) { for(int u=0; u<=thick; u++) { dline( x, y+u, x+w, y+u, color ); dline( x, y+h-u, x+w, y+h-u, color ); dline( x+u, y, x+u, y+h, color ); dline( x+w-u, y, x+w-u, y+h, color ); } } int drawMenuCircuitSelect( void ) { uint16_t pulse=0; doneMenuCircuit = false; CircuitSelection=0; while (!doneMenuCircuit) { dclear( C_BLACK ); dsubimage( 0, 32, &mainscreen, 0, 32, 396, 160, DIMAGE_NONE); dfont(&autofont); dprint_opt(198, 2, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_TOP, "SELECT A CIRCUIT" ); dimage( 16, 45, &plains1 ); dimage( 16, 45, &linear ); if (CircuitSelection!=0) drawRectangle( 16, 45, 60, 60, C_WHITE, 3 ); else { drawRectangle( 16, 45, 60, 60, C_RGB(pulse%256,0,pulse%256), 3 ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">EUROPEAN PLAINS" ); } dimage( 92, 45, &desert1 ); dimage( 92, 45, &linear ); if (CircuitSelection!=1) drawRectangle( 92, 45, 60, 60, C_WHITE, 3 ); else { drawRectangle( 92, 45, 60, 60, C_RGB(pulse%256,0,pulse%256), 3 ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">ATACAMA DESERT" ); } dimage( 168, 45, &usa1 ); dimage( 168, 45, &linear ); if (CircuitSelection!=2) drawRectangle( 168, 45, 60, 60, C_WHITE, 3 ); else { drawRectangle( 168, 45, 60, 60, C_RGB(pulse%256,0,pulse%256), 3 ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">US ROAD 66" ); } dimage( 244, 45, &finland1 ); dimage( 244, 45, &linear ); if (CircuitSelection!=3) drawRectangle( 244, 45, 60, 60, C_WHITE, 3 ); else { drawRectangle( 244, 45, 60, 60, C_RGB(pulse%256,0,pulse%256), 3 ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">SNOW IN FINLAND" ); } dimage( 320, 45, &africa1 ); dimage( 320, 45, &linear ); if (CircuitSelection!=4) drawRectangle( 320, 45, 60, 60, C_WHITE, 3 ); else { drawRectangle( 320, 45, 60, 60, C_RGB(pulse%256,0,pulse%256), 3 ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">KENYAN SAVANAH" ); } dimage( 16, 120, &plains1 ); dimage( 16, 120, &circular ); if (CircuitSelection!=5) drawRectangle( 16, 120, 60, 60, C_WHITE, 3 ); else { drawRectangle( 16, 120, 60, 60, C_RGB(pulse%256,0,pulse%256), 3 ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">EUROPEAN PLAINS" ); } dimage( 92, 120, &desert1 ); dimage( 92, 120, &circular ); if (CircuitSelection!=6) drawRectangle( 92, 120, 60, 60, C_WHITE, 3 ); else { drawRectangle( 92, 120, 60, 60, C_RGB(pulse%256,0,pulse%256), 3 ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">ATACAMA DESERT" ); } dimage( 168, 120, &usa1 ); dimage( 168, 120, &circular ); if (CircuitSelection!=7) drawRectangle( 168, 120, 60, 60, C_WHITE, 3 ); else { drawRectangle( 168, 120, 60, 60, C_RGB(pulse%256,0,pulse%256), 3 ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">US ROAD 66" ); } dimage( 244, 120, &finland1 ); dimage( 244, 120, &circular ); if (CircuitSelection!=8) drawRectangle( 244, 120, 60, 60, C_WHITE, 3 ); else { drawRectangle( 244, 120, 60, 60, C_RGB(pulse%256,0,pulse%256), 3 ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">SNOW IN FINLAND" ); } dimage( 320, 120, &africa1 ); dimage( 320, 120, &circular ); if (CircuitSelection!=9) drawRectangle( 320, 120, 60, 60, C_WHITE, 3 ); else { drawRectangle( 320, 120, 60, 60, C_RGB(pulse%256,0,pulse%256), 3 ); dprint_opt(198, 222, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, ">KENYAN SAVANAH" ); } //dimage( 10, 10+40*CircuitSelection, &flag ); // CODE HERE TO PRINT WELCOME MENU dupdate(); pulse++; getInputCircuitSelect(); #if IS_FXLIB==1 if (screenshot && usb_is_open()) { usb_fxlink_screenshot(false); screenshot = false; } if(record && usb_is_open()) { usb_fxlink_videocapture(false); } #endif if (CircuitSelection==-1) return -1; } return CircuitSelection; } void getInputCircuitSelect( void ) { int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS; int timeout = 1; while(1) { key_event_t ev = getkey_opt(opt, &timeout); if(ev.type == KEYEV_NONE) return; int key = ev.key; if (key==KEY_EXE) doneMenuCircuit = true; if (key==KEY_EXIT) CircuitSelection = -1; if (key==KEY_UP || key==KEY_LEFT) { if (CircuitSelection==0) CircuitSelection=9; else CircuitSelection--; } if (key==KEY_DOWN || key==KEY_RIGHT) { if (CircuitSelection==9) CircuitSelection=0; else CircuitSelection++; } #if IS_FXLIB==1 if(keydown(KEY_F5)) screenshot = true; if(keydown(KEY_F6)) record = !record; #endif // IS_FXLIB } } void drawCredit( void ) { uint16_t pulse=0; int16_t offset=240; doneMenuCredit = false; while (!doneMenuCredit) { dclear( 0x0000 ); dimage( 0, 0, &mainscreen ); dfont(&autofont); dprint_opt(202, offset + 4, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "OUTRUN FOR GRAPH90" ); dprint_opt(200, offset + 2, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_TOP, "OUTRUN FOR GRAPH90" ); dfont(&autofontsmall); dprint_opt(200, offset + 32, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "PROUDLY CODED BY" ); dprint_opt(200, offset + 62, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "SLYVTT / MARCH 2022" ); dfont(&autofont); dprint_opt(202, offset + 124, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "CODE :" ); dprint_opt(200, offset + 122, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "CODE :" ); dfont(&autofontsmall); dprint_opt(200, offset + 162, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "SLYVTT" ); dprint_opt(200, offset + 192, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "WITH SUPPORT FROM LEPHE" ); dfont(&autofont); dprint_opt(202, offset + 254, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "VISUALS" ); dprint_opt(200, offset + 252, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "VISUALS" ); dfont(&autofontsmall); dprint_opt(200, offset + 292, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "SLYVTT" ); dprint_opt(200, offset + 322, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "WITH SUPPORT FROM INTERNET" ); dprint_opt(200, offset + 352, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "GOOGLE IS MY BEST FRIEND" ); dfont(&autofont); dprint_opt(202, offset + 414, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "MUSIC" ); dprint_opt(200, offset + 412, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "MUSIC" ); dfont(&autofontsmall); dprint_opt(200, offset + 452, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "SORRY, NO MUSIC ..." ); dprint_opt(200, offset + 482, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "... MAYBE ONE DAY !!!" ); dfont(&autofont); dprint_opt(202, offset + 544, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "THANKS FOR PLAYING" ); dprint_opt(202, offset + 574, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "HOPE YOU ENJOYED" ); dprint_opt(200, offset + 542, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_TOP, "THANKS FOR PLAYING" ); dprint_opt(200, offset + 572, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_CENTER, DTEXT_TOP, "HOPE YOU ENJOYED" ); dupdate(); #if IS_FXLIB==1 if (screenshot && usb_is_open()) { usb_fxlink_screenshot(false); screenshot = false; } if(record && usb_is_open()) { usb_fxlink_videocapture(false); } #endif pulse++; offset--; getInputCredit(); } return; } void getInputCredit( void ) { int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS; int timeout = 1; while(1) { key_event_t ev = getkey_opt(opt, &timeout); if(ev.type == KEYEV_NONE) return; int key = ev.key; if (key==KEY_EXE) doneMenuCredit = true; #if IS_FXLIB==1 if(keydown(KEY_F5)) screenshot = true; if(keydown(KEY_F6)) record = !record; #endif // IS_FXLIB } } void drawOptions( void ) { uint16_t pulse=0; doneOptions = false; OptionsSelection=0; while (!doneOptions) { dclear(0x0000); dimage( 0, 0, &mainscreen); dfont(&autofont); if (BDrawDeco) { dprint_opt(94, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [Y]" ); if (OptionsSelection!=0) dprint_opt(92, 20, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [Y]" ); else dprint_opt(92, 20, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [Y]" ); } else { dprint_opt(94, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [N]" ); if (OptionsSelection!=0) dprint_opt(92, 20, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [N]" ); else dprint_opt(92, 20, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "SCENERY [N]" ); } if (BDrawCars) { dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [Y]" ); if (OptionsSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [Y]" ); else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [Y]" ); } else { dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [N]" ); if (OptionsSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [N]" ); else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "OPPONENTS [N]" ); } if (BDrawClds) { dprint_opt(94, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [Y]" ); if (OptionsSelection!=2) dprint_opt(92, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [Y]" ); else dprint_opt(92, 80, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [Y]" ); } else { dprint_opt(94, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [N]" ); if (OptionsSelection!=2) dprint_opt(92, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [N]" ); else dprint_opt(92, 80, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CLOUDS [N]" ); } if (BDrawBack) { dprint_opt(94, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [Y]" ); if (OptionsSelection!=3) dprint_opt(92, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [Y]" ); else dprint_opt(92, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [Y]" ); } else { dprint_opt(94, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [N]" ); if (OptionsSelection!=3) dprint_opt(92, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [N]" ); else dprint_opt(92, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACKGROUND [N]" ); } if (BDrawFPS) { dprint_opt(94, 142, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [Y]" ); if (OptionsSelection!=4) dprint_opt(92, 140, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [Y]" ); else dprint_opt(92, 140, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [Y]" ); } else { dprint_opt(94, 142, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [N]" ); if (OptionsSelection!=4) dprint_opt(92, 140, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [N]" ); else dprint_opt(92, 140, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "STATS-FPS [N]" ); } dprint_opt(94, 172, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" ); if (OptionsSelection!=5) dprint_opt(92, 170, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" ); else dprint_opt(92, 170, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" ); dimage( 2, 5+30*OptionsSelection, &flag ); // CODE HERE TO PRINT WELCOME MENU dupdate(); pulse++; getInputOptions(); #if IS_FXLIB==1 if (screenshot && usb_is_open()) { usb_fxlink_screenshot(false); screenshot = false; } if(record && usb_is_open()) { usb_fxlink_videocapture(false); } #endif } SkipTime = true; // To avoid counting or de-counting time during menu return; } void getInputOptions( void ) { int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS; int timeout = 1; while(1) { key_event_t ev = getkey_opt(opt, &timeout); if(ev.type == KEYEV_NONE) return; int key = ev.key; if (key==KEY_EXE) { if (OptionsSelection==0) BDrawDeco = !BDrawDeco; else if (OptionsSelection==1) BDrawCars = !BDrawCars; else if (OptionsSelection==2) BDrawClds = !BDrawClds; else if (OptionsSelection==3) BDrawBack = !BDrawBack; else if (OptionsSelection==4) BDrawFPS = !BDrawFPS; else doneOptions=true; } if (key==KEY_UP) { if (OptionsSelection==0) OptionsSelection=5; else OptionsSelection--; } if (key==KEY_DOWN) { if (OptionsSelection==5) OptionsSelection=0; else OptionsSelection++; } #if IS_FXLIB==1 if(keydown(KEY_F5)) screenshot = true; if(keydown(KEY_F6)) record = !record; #endif // IS_FXLIB } } void drawGameOptions( void ) { uint16_t pulse=0; doneGameOptions = false; GameOptionsSelection=0; selectedChar = 0; while (!doneGameOptions) { dclear(0x0000); dimage( 0, 0, &mainscreen); dfont(&autofont); if (DiffLevel==0) { dprint_opt(94, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "LVL " ); if (GameOptionsSelection!=0) dprint_opt(92, 20, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "LVL " ); else dprint_opt(92, 20, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "LVL " ); } else if (DiffLevel==1) { dprint_opt(94, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "LVL " ); if (GameOptionsSelection!=0) dprint_opt(92, 20, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "LVL " ); else dprint_opt(92, 20, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "LVL " ); } else if (DiffLevel==2) { dprint_opt(94, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "LVL " ); if (GameOptionsSelection!=0) dprint_opt(92, 20, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "LVL " ); else dprint_opt(92, 20, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "LVL " ); } if (CarsNumb==0) { dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <50>" ); if (GameOptionsSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <50>" ); else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <50>" ); } else if (CarsNumb==1) { dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <100>" ); if (GameOptionsSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <100>" ); else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <100>" ); } else if (CarsNumb==2) { dprint_opt(94, 52, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <200>" ); if (GameOptionsSelection!=1) dprint_opt(92, 50, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <200>" ); else dprint_opt(92, 50, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "CARS <200>" ); } dprint_opt(94, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "PLAYER" ); dprint_opt(92, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "PLAYER" ); dprint_opt(124, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%c", PlayerName[0] ); if (GameOptionsSelection!=2 || selectedChar!=0) dprint_opt(122, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%c", PlayerName[0] ); else if (GameOptionsSelection==2 && selectedChar==0) dprint_opt(122, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%c", PlayerName[0] ); dprint_opt(154, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%c", PlayerName[1] ); if (GameOptionsSelection!=2 || selectedChar!=1) dprint_opt(152, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%c", PlayerName[1] ); else if (GameOptionsSelection==2 && selectedChar==1) dprint_opt(152, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%c", PlayerName[1] ); dprint_opt(184, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%c", PlayerName[2] ); if (GameOptionsSelection!=2 || selectedChar!=2) dprint_opt(182, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%c", PlayerName[2] ); else if (GameOptionsSelection==2 && selectedChar==2) dprint_opt(182, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%c", PlayerName[2] ); dfont(&speedfont); dprint_opt(214, 112, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "@" ); if (GameOptionsSelection!=2 || selectedChar!=3) dprint_opt(212, 110, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "@" ); else if (GameOptionsSelection==2 && selectedChar==3) dprint_opt(212, 110, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "@" ); dfont(&autofont); dprint_opt(94, 172, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" ); if (GameOptionsSelection!=3) dprint_opt(92, 170, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" ); else dprint_opt(92, 170, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO GAME" ); if (GameOptionsSelection==0) dimage( 2, 5, &flag ); else if (GameOptionsSelection==1) dimage( 2, 35, &flag ); else if (GameOptionsSelection==2) dimage( 2, 65, &flag ); else if (GameOptionsSelection==3) dimage( 2, 155, &flag ); // CODE HERE TO PRINT WELCOME MENU dupdate(); pulse++; getInputGameOptions(); #if IS_FXLIB==1 if (screenshot && usb_is_open()) { usb_fxlink_screenshot(false); screenshot = false; } if(record && usb_is_open()) { usb_fxlink_videocapture(false); } #endif } SkipTime = true; // To avoid counting or de-counting time during menu return; } void getInputGameOptions( void ) { int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS; int timeout = 1; while(1) { key_event_t ev = getkey_opt(opt, &timeout); if(ev.type == KEYEV_NONE) return; int key = ev.key; if (key==KEY_EXE) { if (GameOptionsSelection==2) nameCurrentlyWritten=false; if (GameOptionsSelection==3) doneGameOptions=true; } if (key==KEY_UP && !nameCurrentlyWritten) { if (GameOptionsSelection==0) GameOptionsSelection=3; else GameOptionsSelection--; } if (key==KEY_UP && nameCurrentlyWritten) { if(GameOptionsSelection==2 && selectedChar>=0 && selectedChar<=2) { if (PlayerName[selectedChar]>'A') PlayerName[selectedChar]--; else PlayerName[selectedChar]='Z'; } else if(GameOptionsSelection==2 && selectedChar==3) { nameCurrentlyWritten=false; } } if (key==KEY_DOWN && !nameCurrentlyWritten) { if (GameOptionsSelection==3) GameOptionsSelection=0; else GameOptionsSelection++; } if (key==KEY_DOWN && nameCurrentlyWritten) { if(GameOptionsSelection==2 && selectedChar>=0 && selectedChar<=2) { if (PlayerName[selectedChar]<'Z') PlayerName[selectedChar]++; else PlayerName[selectedChar]='A'; } else if(GameOptionsSelection==2 && selectedChar==3) { nameCurrentlyWritten=false; } } if (key==KEY_LEFT) { if (GameOptionsSelection==2 && selectedChar>=0 && selectedChar<=2) nameCurrentlyWritten=true; else if (GameOptionsSelection==2 && selectedChar==3) nameCurrentlyWritten=false; if (GameOptionsSelection==2 && selectedChar>0) selectedChar--; else if (GameOptionsSelection==2) selectedChar=3; if (GameOptionsSelection==0 && DiffLevel>0) DiffLevel--; else if (GameOptionsSelection==1 && CarsNumb>0) CarsNumb--; } if (key==KEY_RIGHT) { if (GameOptionsSelection==2 && selectedChar>=0 && selectedChar<=2) nameCurrentlyWritten=true; else if (GameOptionsSelection==2 && selectedChar==3) nameCurrentlyWritten=false; if (GameOptionsSelection==2 && selectedChar<4) selectedChar++; else if (GameOptionsSelection==2) selectedChar=0; if (GameOptionsSelection==0 && DiffLevel<2) DiffLevel++; else if (GameOptionsSelection==1 && CarsNumb<2) CarsNumb++; } #if IS_FXLIB==1 if(keydown(KEY_F5)) screenshot = true; if(keydown(KEY_F6)) record = !record; #endif // IS_FXLIB } } void drawPauseQuit( void ) { uint16_t pulse=0; donePauseQuit = false; PauseQuitSelection=0; while (!donePauseQuit) { dclear(0x0000); dimage( 0, 0, &mainscreen); dfont(&autofont); dprint_opt(102, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "GAME PAUSED" ); dprint_opt(100, 20, C_RGB(255,0,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "GAME PAUSED" ); dprint_opt(102, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "FINISH RACE" ); if (PauseQuitSelection!=0) dprint_opt(100, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "FINISH RACE" ); else dprint_opt(100, 80, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "FINISH RACE" ); dprint_opt(102, 122, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "MAIN MENU" ); if (PauseQuitSelection!=1) dprint_opt(100, 120, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "MAIN MENU" ); else dprint_opt(100, 120, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "MAIN MENU" ); dprint_opt(102, 162, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO OS" ); if (PauseQuitSelection!=2) dprint_opt(100, 160, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO OS" ); else dprint_opt(100, 160, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO OS" ); dimage( 10, 70+40*PauseQuitSelection, &flag ); // CODE HERE TO PRINT WELCOME MENU dupdate(); pulse++; getInputPauseQuit(); #if IS_FXLIB==1 if (screenshot && usb_is_open()) { usb_fxlink_screenshot(false); screenshot = false; } if(record && usb_is_open()) { usb_fxlink_videocapture(false); } #endif } SkipTime = true; // To avoid counting or de-counting time during menu return; } void getInputPauseQuit( void ) { int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS; int timeout = 1; while(1) { key_event_t ev = getkey_opt(opt, &timeout); if(ev.type == KEYEV_NONE) return; int key = ev.key; if (key==KEY_EXE) { if (PauseQuitSelection==0) { donePauseQuit=true; } else if (PauseQuitSelection==1) { stop=true; donePauseQuit=true; } else if (PauseQuitSelection==2) { stop =true; exitToOS=true; donePauseQuit=true; } } if (key==KEY_UP) { if (PauseQuitSelection==0) PauseQuitSelection=2; else PauseQuitSelection--; } if (key==KEY_DOWN) { if (PauseQuitSelection==2) PauseQuitSelection=0; else PauseQuitSelection++; } #if IS_FXLIB==1 if(keydown(KEY_F5)) screenshot = true; if(keydown(KEY_F6)) record = !record; #endif // IS_FXLIB } }