// function to draw the main menu void drawWords(unsigned int difficulty) { char * diffStr; if (difficulty == VERY_EASY) diffStr = (char *)"Very Easy"; if (difficulty == EASY) diffStr = (char *)"Easy"; if (difficulty == NORMAL) diffStr = (char *)"Normal"; if (difficulty == HARD) diffStr = (char *)"Hard"; if (difficulty == VERY_HARD) diffStr = (char *)"Very Hard"; if (difficulty == IMPOSSIBLE) diffStr = (char *)"Impossible!"; FontSetSys(F_8x10); GraySetAMSPlane(LIGHT_PLANE); DrawStr(20,20,"Play", A_NORMAL); DrawStr(20,35,"Diff -", A_NORMAL); DrawStr(80,35,diffStr, A_NORMAL); DrawStr(20,50,"High Scores", A_NORMAL); DrawStr(20,65,"Help", A_NORMAL); DrawStr(20,80,"Exit",A_NORMAL); GraySetAMSPlane(DARK_PLANE); DrawStr(20,20,"Play", A_NORMAL); DrawStr(20,35,"Diff -", A_NORMAL); DrawStr(80,35,diffStr, A_NORMAL); DrawStr(20,50,"High Scores", A_NORMAL); DrawStr(20,65,"Help", A_NORMAL); DrawStr(20,80,"Exit",A_NORMAL); FontSetSys(F_6x8); }
// function to let the user type in a name for the hi-scores void getName(unsigned long int score) { int key = 0; int x = 0; int y = 45; int back = 0; clrscr(); GrayOff(); FontSetSys(F_8x10); printf_xy(20,0,"New High Score!"); printf_xy(60,12,"%lu", score); FontSetSys(F_4x6); printf_xy(53,95,"Jet Blaster v 1.0 by Ben Cherry"); FontSetSys(F_6x8); printf_xy(11,25,"Please Enter Your Name:"); while (key != KEY_ENTER) { key = ngetchx(); if (key == KEY_BACKSPACE) { if (x>0) x--; key = (int)' '; back = 1; } if (x <= 9 && key != KEY_ENTER) { printf_xy(6*x+50,y,"%c",(char)key); hiScores[0].name[x] = key; } if (!back && x <= 9) x++; if (back) back--; } clrscr(); }
void _main(void) { short int font = FontGetSys(), speed = AVERAGE, difficulty = NORMAL; // create the hiscore file, if it doesn't exist if (needScoreFile()) { createHiScoreTable(); } // Make sure there are no keystrokes left in the buffer GKeyFlush(); // setup medium size font FontSetSys(F_6x8); // seed the random number generator randomize(); // disable interrupts OSSetSR(0x0700); // keep playing until doIntro returns FALSE (exit) while (doIntro(&speed,&difficulty)) { play(speed,difficulty); } // reenable interrupts before exit OSSetSR(0x0000); // restore the standard font FontSetSys(font); }
//draws the box on the screen void drawBox(WIN_RECT box, char value){ DrawClipRect(&box,ScrRect,A_NORMAL); if(value == 17) FontSetSys(F_4x6);//Make Text even more smaller for even more bigger numbers else if(value>13) FontSetSys(F_6x8);//Make text smaller for bigger numbers /*This game does not support going over 2^17 = 131072 and you can't exceed that value in a normal game anyways. this check prevents accessing bad memory*/ DrawStr((box.x0)+2, (box.y0)+5, strConv[value], A_NORMAL); FontSetSys(F_8x10); }
/*===========================================================================*/ void _main(void) { short i,j; unsigned long measure_val; char tmpstr[50] = "Measuring, please wait ..."; short modes[6] = { A_REPLACE,A_XOR,A_REVERSE,A_XOR,A_REPLACE,A_REVERSE}; LCD_BUFFER screen; LCD_save(screen); FontSetSys(F_4x6); OSFreeTimer(USER_TIMER); OSRegisterTimer(USER_TIMER,INITIAL_TIMER_VALUE); ClearScreen(); DrawStr(0,0,tmpstr,A_REPLACE); do { //--------------------------------------------------------------------- // built-in OS line drawing routine ... //--------------------------------------------------------------------- OSTimerRestart(USER_TIMER); for (j=0;j<6 && !kbhit();j++) { short used_mode = modes[j]; for (i=0; i<160;i++) DrawLine(80,50,i,8, used_mode); for (i=8; i<100;i++) DrawLine(80,50,159,i, used_mode); for (i=159;i>=0; i--) DrawLine(80,50,i,99, used_mode); for (i=99; i>=8; i--) DrawLine(80,50,0,i, used_mode); } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"OS Routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val); memset(LCD_MEM,0,30*8); DrawStr(0,0,tmpstr,A_REPLACE); if (kbhit()) break; //--------------------------------------------------------------------- // new line drawing routine ... //--------------------------------------------------------------------- OSTimerRestart(USER_TIMER); for (j=0;j<6 && !kbhit();j++) { short used_mode = modes[j]; for (i=0; i<160;i++) FastDrawLine_R(LCD_MEM,80,50,i,8, used_mode); for (i=8; i<100;i++) FastDrawLine_R(LCD_MEM,80,50,159,i, used_mode); for (i=159;i>=0; i--) FastDrawLine_R(LCD_MEM,80,50,i,99, used_mode); for (i=99; i>=8; i--) FastDrawLine_R(LCD_MEM,80,50,0,i, used_mode); } measure_val = OSTimerCurVal(USER_TIMER); sprintf(tmpstr,"Own Routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val); memset(LCD_MEM,0,30*8); DrawStr(0,0,tmpstr,A_REPLACE); } while (!kbhit()); ngetchx(); OSFreeTimer(USER_TIMER); LCD_restore(screen); GKeyFlush(); ST_helpMsg(EXTGRAPH_VERSION_PWDSTR); }
static inline void info(void) { int loop; const char * const str[12] = {"Plinko V 1.0", "By Travis Fischer", "", "Win as many plinko chips as you can", "by guessing the correct digit in the", "price of the given product.", "Then, drop your chips down the plinko board", "and win BIG!!!", "--July 6, 2003--", "", "Thanks to the TIGCC team and everyone at tict", "*****@*****.**"}; char buffer[45]; ClearGrayScreen2B(Hiddenl, Hiddend); FontSetSys (F_4x6); for(loop = 0; loop < 12; loop ++) { sprintf (buffer, "%s", str[loop]); GrayDBufSetHiddenAMSPlane (LIGHT_PLANE); DrawStr((LCD_WIDTH - DrawStrWidth(buffer, F_4x6))/2 + 1, 1 + 8 * loop, buffer, A_NORMAL); GrayDBufSetHiddenAMSPlane (DARK_PLANE); DrawStr((LCD_WIDTH - DrawStrWidth(buffer, F_4x6))/2, 8 * loop, buffer, A_NORMAL); //DrawGrayStrExt2B(0, 8 * loop, (char*)str[loop], A_NORMAL|A_SHADOWED|A_CENTERED, F_4x6, //Hiddenl, Hiddend); } GrayDBufToggleSync(); // switches two sets of planes wait_for_keypress(); }
// Main Function void _main(void) { typedef struct { long int score; char * name; } hiscore; int i = 0; hiscore hiScoreArray[5] = {{20000,"ben cherry"},{20000,"ben cherry"},{20000,"ben cherry"},{20000,"ben cherry"},{20000,"ben cherry"}}; clrscr(); FontSetSys(F_8x10); printf_xy(36,0,"Jet Blaster"); printf_xy(36,12,"High Scores"); FontSetSys(F_4x6); printf_xy(53,95,"Jet Blaster v 1.0 by Ben Cherry"); FontSetSys(F_6x8); for (i = 0; i <= 4; i++) { printf_xy(10,i*9 + 26,"%d. %s - %d",i+1,hiScoreArray[i].name,hiScoreArray[i].score); } ngetchx(); }
// prints the hi-score table void printHiScores(void) { int i = 0; GraySetAMSPlane(DARK_PLANE); clrscr(); GraySetAMSPlane(LIGHT_PLANE); clrscr(); GraySetAMSPlane(DARK_PLANE); FontSetSys(F_8x10); DrawStr(36,0,"Jet Blaster",A_NORMAL); DrawStr(36,12,"High Scores",A_NORMAL); FontSetSys(F_4x6); DrawStr(53,95,"Jet Blaster v 1.0 by Ben Cherry",A_NORMAL); FontSetSys(F_6x8); for (i = 1; i <= 5; i++) { printf_xy(10,i*9 + 26,"%d. %s - %lu",i,hiScores[i].name,hiScores[i].score); } GraySetAMSPlane(LIGHT_PLANE); FontSetSys(F_8x10); printf_xy(36,0,"Jet Blaster"); printf_xy(36,12,"High Scores"); FontSetSys(F_4x6); printf_xy(53,95,"Jet Blaster v 1.0 by Ben Cherry"); FontSetSys(F_6x8); for (i = 1; i <= 5; i++) { printf_xy(10,i*9 + 26,"%d. %s - %lu",i,hiScores[i].name,hiScores[i].score); } while (ngetchx() != KEY_ENTER); GraySetAMSPlane(DARK_PLANE); clrscr(); GraySetAMSPlane(LIGHT_PLANE); clrscr(); }
void _main(void) { short i_menu_choice; graph *p_graph = NULL; matrix *p_matrix = NULL; point v_key[8]; ESI EsiPtr = top_estack; //pointer en haut de la pile FontSetSys(F_6x8); clrscr(); //Verifie si une matrice est passée en parametre if((GetArgType(EsiPtr) != LIST_TAG)||(GetArgType(EsiPtr-1) != LIST_TAG)){ //Ce n'est pas une matrice EsiPtr = open_file(); //Si ce n'est pas la cas, ouvrir une fenetre } //sym = DerefSym(SymFind(GetSymstrArg(EsiPtr))); if(! is_square_matrix(EsiPtr)){ printf("\Error : The matrix must be a squared matrix (same height and width). "); ngetchx(); exit(0); }
void _main(void) { char str[30]; ClrScr (); FontSetSys (F_8x10); sprintf(str, "RomDumper v%s", VERSION); DrawStr(0, 0, str, A_NORMAL); sprintf(str, "Type: HW%i", HW_VERSION); DrawStr(0, 20, str, A_NORMAL); sprintf(str, "ROM base: 0x%lx", (uint32_t)ROM_base); DrawStr(0, 40, str, A_NORMAL); sprintf(str, "by The TiLP Team"); DrawStr(0, 80, str, A_NORMAL); Dump(); return; }
// drawCopyright - prints the copyright notice at the bottom of the screen inline void drawCopyright(void) { FontSetSys(F_4x6); DrawStr(COPYX,COPYY,(char *)intro[COPYRIGHT],A_XOR); DrawStr(URLX,URLY,(char *)intro[URL],A_XOR); FontSetSys(F_6x8); }
// drawHiScoreBoard - draws the hiscore board, and updates it with the hiscore from the latest game void drawHiScoreBoard(unsigned long int newscore) { SCORE scores[MAX_HISCORES]; short int loop, pos = -1; char name[10], str[50], *error = "File I/O Error"; HANDLE dlg; // restore interrupt handlers OSSetSR(0x0000); if (!loadHiScores(scores)) { // cannot open hiscore file -- display error DlgMessage(error,"Unable to Load HiScore Data",BT_OK,BT_NONE); return; } // check if latest score is a highscore for (loop = (MAX_HISCORES - 1); loop >= 0; loop--) { if (newscore > scores[loop].score) { // new HiScore!! pos = loop; } } if (pos != -1) { // if we found a new hiscore if ((dlg = DialogNewSimple(DLGWIDTH,DLGHEIGHT)) == H_NULL) { DlgMessage("Memory Allocation Error","Not Enough Free Memory!",BT_OK,BT_NONE); } else { DialogAddTitle(dlg,"New Hiscore!",BT_OK,BT_NONE); DialogAddRequest(dlg,5,25,"Your Name:",0,9,11); sprintf(str,"You earned the #%hd hiscore position!",pos+1); DialogAddText(dlg,5,15,str); do { // truncate name variable name[0] = 0; } while (DialogDo(dlg,CENTER,CENTER,name,NULL) != KEY_ENTER); // free the dialog box memory HeapFree(dlg); // move the hiscore list down if (pos < (MAX_HISCORES - 1)) { for (loop = (MAX_HISCORES - 1); loop > pos; loop--) { scores[loop].score = scores[loop - 1].score; scores[loop].name[0] = 0; strcpy(scores[loop].name,scores[loop - 1].name); } } // fill in the new hiscore scores[pos].score = newscore; scores[pos].name[0] = 0; strcpy(scores[pos].name,name); if (!saveHiScores(scores)) { DlgMessage(error,"Unable to save HiScore Board",BT_OK,BT_NONE); } } } // display the hiscore board // clear the screen ClrScr(); // draw the screen borders drawBorder(); // draw the game logo drawLogo(); FontSetSys(F_8x10); DrawStr(25,35,"Hiscore Board",A_NORMAL); FontSetSys(F_6x8); for (loop = 0; loop < 5; loop++) { printf_xy(20,50+loop*10,"#%hd %-9s %lu",loop+1,scores[loop].name,scores[loop].score); } ngetchx(); // disable interrupts OSSetSR(0x0700); // wait for keypresses to dissipate delay(KEYDELAY); }
// Main Function void _main(void) { signed char STATUS, a; int plinkos; unsigned char *Home = malloc(LCD_SIZE); // Allocate the SAVE_SCREEN buffer if (Home == NULL) { Error_Memory(); return; } LCD_save(Home); // Save LCD HomeScreen Contents virtual_dark = malloc ( LCD_SIZE ); // Allocate the dark buffer if (virtual_dark == NULL) {Error_Memory(); return; } virtual_light=malloc ( LCD_SIZE ); // Allocate the light buffer if (virtual_light == NULL) { free(virtual_dark); Error_Memory(); return; } randomize(); if (Gray_prep() == QUIT) { Error_Memory(); goto end; } if (makefile() == QUIT) // Tests whether or not we need a default save file and installs one if the // user doesn't already have one on their calc goto end; for(a = 10; a--;) FADE_LIGHTER(); // Clears both Hidden Gray planes ClearGrayScreen2B(Hiddenl, Hiddend); GraySpriteX8_OR(52, 37, 27, titlel, titled, 7, Hiddenl, Hiddend); FontSetSys (F_4x6); GrayDBufSetHiddenAMSPlane (DARK_PLANE); DrawStr(122, 94, "-- By Fisch", A_NORMAL); GrayDBufSetHiddenAMSPlane (LIGHT_PLANE); DrawStr(123, 95, "-- By Fisch", A_NORMAL); GrayDBufToggleSync(); // switches two sets of planes for(a = 10; a--;) FADE_DARKER(); Waitkey(); NEW_GAME: if ((STATUS = MENU()) == QUIT) goto end; if ((plinkos = PRODUCTS()) == QUIT) goto end; if ((STATUS = INTRO()) == QUIT) goto end; if ((STATUS = main_game(plinkos)) == QUIT) goto end; goto NEW_GAME; end: // Clean up at end of Program Cleanup(); if (Home) { LCD_restore(Home); free(Home); GKeyFlush(); ST_helpMsg("Plinko --By Travis Fischer"); } }
static inline char main_game(unsigned char plinkos) { unsigned char STATUS = RUNNING, x, y = 0, oldx = 59; unsigned int Amount, Total = 0; char buffer[15]; FontSetSys(F_4x6); while( plinkos-- ) { ClearGrayScreen2B(virtual_dark, virtual_light); GraySpriteX8_OR(0, 0, 100, plinkol, plinkod, 20, virtual_light, virtual_dark); PRINT_TOTAL(Total); SHOW_PLINKOS(5, plinkos - 1, virtual_light, virtual_dark); new_chip(oldx, plinkos); x = oldx; y = 2; DRAWALL(x, y); while (STATUS == RUNNING) { if (_keytest (RR_LEFT) && x > 3) MOVE_LEFT( &x ); if (_keytest (RR_RIGHT) && x < 115) MOVE_RIGHT( &x ); if (_keytest (RR_ESC)) STATUS = EXIT; if (_keytest (RR_2ND) || _keytest (RR_DOWN)) STATUS = DROP; } if (STATUS == EXIT) return -1; oldx = x; Amount = DROPPING( &x ); // After this, x will be from 0 to 8 if (Amount == EXIT) return -1; Total += Amount; //GRAPHIC(30, 20, /* HEIGHT */14, /* WIDTH */32, (char*) Zerol, (char*) Zerod, SMALL); /*for(y = 1; y < 6; y++) { period = 15000*(1+random( y )); memset (Actived, 255, LCD_SIZE); // clear virtual gray planes memset (Activel, 255, LCD_SIZE); for(wait = 1; wait < period; wait++); period = 15000*(1+random( y )); DRAWALL(14 * x + 3, 93); for(wait = 1; wait < period; wait++); }*/ SHUFFLE( x ); DRAWALL(14 * x + 3, 93); DRAWALL(14 * x + 3, 93); GRAPHIC(45, 36, x, FALSE);//, gfx_light[x], gfx_dark[x], x); GrayDBufToggleSync(); // switches two sets of planes Waitkey() STATUS = RUNNING; } sprintf(buffer, "Score %d", Total); x = (LCD_WIDTH - DrawStrWidth(buffer, F_6x8)) / 2 - 16; DrawGrayStrExt2B(x, 2, (char*)buffer, A_NORMAL|A_SHADOWED, F_6x8, Activel, Actived); wait_for_keypress(); if (CHECK_FOR_HIGH(Total) == QUIT) // Checks whether or not the user got a high score, writes a new // high score if they did get one, and calls a function to display the new high scores return QUIT; return STATUS; }
// Main Function void _main( void ){ //Create or load savefile SAVE gameState; if(readSave(&gameState)) makeSave(&gameState); writeSave(&gameState); /*just to test whether writing is possible here so the player doesn't spend a long time and lose their progress*/ //Buffer for the text at the bottom of the scoreString = (char*)malloc(60*sizeof(char)); if(scoreString == NULL) exit(ER_MEMORY); //Pause menu pauseMenu = PopupNew(strConv[11], 50); if(pauseMenu == H_NULL) memkill(4, ER_MEMORY); PopupAddText(pauseMenu, -1, "New Game", 1); PopupAddText(pauseMenu, 0, "Options", 2); PopupAddText(pauseMenu,2,"Toggle Animations",5); PopupAddText(pauseMenu,2,"Reset Save Data",6); PopupAddText(pauseMenu, -1, "Exit", 3); PopupAddText(pauseMenu, -1, "About", 4); //Hiscore Name Entry nameBox = DialogNewSimple(140,35); if(nameBox == H_NULL) memkill(3, ER_MEMORY); DialogAddTitle(nameBox,"NEW HISCORE!",BT_OK,BT_NONE); DialogAddRequest(nameBox,3,14,"Name:", 0, 10, 14); //Game Over Entry gameOver = PopupNew("GAME OVER!", 40); if(gameOver == H_NULL) memkill(2, ER_MEMORY); PopupAddText(gameOver,-1,"Try Again",1); PopupAddText(gameOver,-1,"Exit",2); //About Dialouge aboutBox = DialogNewSimple(140,80); if(aboutBox == H_NULL) memkill(1, ER_MEMORY); DialogAddTitle(aboutBox,"ABOUT",BT_OK,BT_NONE); DialogAddText(aboutBox, 3, 13, "2048: A sliding tile puzzle"); DialogAddText(aboutBox, 3, 21, "Ti68k port by Harrison Cook"); DialogAddText(aboutBox, 3, 29, "Original game by Gabriele Cirulli"); DialogAddText(aboutBox, 3, 37, "\"Based on\" 1024 by Veewo Studio"); DialogAddText(aboutBox, 3, 45, "\"Conceptually Similar to\":"); DialogAddText(aboutBox, 3, 52, "Threes by Asher Vollmer"); DialogAddText(aboutBox, 3, 59, "Built using TIGCC"); ClrScr(); FontSetSys(F_8x10); randomize(); short int key; for(;;){ ClrScr(); drawGrid(gameState.grid); sprintf(scoreString, "Score: %lu Hiscore: %lu by %s", gameState.score, gameState.bscore, gameState.name); if(!isGridAvailable(gameState.grid)){ if(gameState.score > gameState.bscore){ DialogDo(nameBox,CENTER,CENTER, gameState.name,NULL); gameState.bscore = gameState.score; FontSetSys(F_8x10); } gameState.score = 0; initGrid(gameState.grid); switch(PopupDo(gameOver,CENTER,CENTER,0)){ case 1: continue; break; default: goto endGame; } } ST_helpMsg(scoreString); nodraw: ST_busy(ST_IDLE); key = ngetchx(); ST_busy(ST_BUSY); ST_helpMsg(scoreString); char move = 4; if(key == KEY_UP) move = UP; else if(key == KEY_RIGHT) move = RIGHT; else if(key == KEY_DOWN) move = DOWN; else if(key == KEY_LEFT) move = LEFT; else if(key == KEY_OFF || key==KEY_ON) //Turn the calculator off during a game. Resume it later off(); else if(key == KEY_ESC){ //Brings up the pause menu switch (PopupDo(pauseMenu,CENTER,CENTER,0)){ case 1: //1. New Game gameState.score = 0; initGrid(gameState.grid); break; //case 2: //2. Options //this is a submenu case 3: //3: Exit endGame: writeSave(&gameState); memkill(0,0); break; case 4: //4: About DialogDo(aboutBox,CENTER,CENTER,NULL,NULL); //Dialog sets the font weirdly, set it back FontSetSys(F_8x10); break; case 5: //1. Toggle Animations gameState.animations = !gameState.animations; break; case 6: //2. Reset Saved Data makeSave(&gameState); break; } } else goto nodraw; if(move < 4){ if(isDirectionAvailable(gameState.grid, move)){ shiftGrid(gameState.grid,move,&gameState.score, gameState.animations); pushNewTile(gameState.grid); } else goto nodraw; } } }