void ChartMidpointRelation() { int cs[cSign + 1]; char sz[cchSzDef]; int mcut = -1, icut=-1, jcut=-1, mlo=-1, ilo=-1, jlo=-1, m, i, j, count = 0, l; long lSpanSum = 0; char ignoreT[objMax]; if (us.nRel == rcTransit) { for (l = 0; l <= cObjOpt; l++) ignoreT[l] = FIgnore2(l); } else if (us.nRel == rcProgress) { for (l = 0; l <= cObjOpt; l++) ignoreT[l] = FIgnore3(l); } else { for (l = 0; l <= cObjOpt; l++) ignoreT[l] = FIgnore(l); } ClearB((lpbyte)cs, (cSign + 1)*(int)sizeof(int)); loop { mlo = 21600; /* Search for the next closest midpoint farther down in the zodiac. */ for (i = 0; i <= cObjOpt; i++) if (!FIgnore(i)) for (j = 0; j <= cObjOpt; j++) if (!ignoreT[j]) { m = (grid->n[j][i]-1)*30*60 + grid->v[j][i]; if ((m > mcut || (m == mcut && (i > icut || (i == icut && j > jcut)))) && m < mlo) { ilo = i; jlo = j; mlo = m; } } if (mlo >= 21600) /* Exit when no midpoint farther in zodiac found. */ break; mcut = mlo; icut = ilo; jcut = jlo; count++; /* Display the current midpoint. */ #ifdef INTERPRET if (us.fInterpret) { /* Interpret it if -I in effect. */ InterpretMidpointRelation(ilo, jlo); continue; } #endif cs[mlo/60/30+1]++; sprintf(sz, "%4d: ", count); PrintSz(sz); PrintZodiac((real)mlo/60.0); PrintCh(' '); PrintAspect(ilo, SFromZ(cp1.obj[ilo]), (int)RSgn(cp1.dir[ilo]), 0, jlo, SFromZ(cp2.obj[jlo]), (int)RSgn(cp2.dir[jlo]), 'M'); AnsiColor(kDefault); m = (int)(MinDistance(cp1.obj[ilo], cp2.obj[jlo])*60.0); lSpanSum += m; sprintf(sz, "-%4d%c%02d' degree span.\n", m/60, chDeg1, m%60); PrintSz(sz); } PrintMidpointSummary(cs, count, lSpanSum); }
// ************* Buttons ************* // this is the major function that handles the button presses // such as movements, attack, and mute, this function will // also check if the game has been won or lost and restart // the input is an int containing buttons that were pressed void Buttons(int keyPressed){ if (gameEnd == WON){ // win DisableInterrupts(); ClearLCDgameStarted(); // displays win banner LCD12864ImageDraw(&display[0],&room[0],&youWin[0],WIN_X,WIN_Y,WIN_WIDTH,WIN_HEIGHT); LCD12864PartUpdate(&display[0],WIN_X,WIN_Y,WIN_WIDTH,WIN_HEIGHT); SysTick_Wait10ms((GAME_RESTART_DELAY)/10); // wait 2 seconds to start game over Game_Init(); keyPressed = 0; EnableInterrupts(); Music_Play(); } else if (gameEnd == LOST){ // lose DisableInterrupts(); ClearLCDgameStarted(); // displays lose banner LCD12864ImageDraw(&display[0],&room[0],&gameOver[0],LOSE_X,LOSE_Y,LOSE_WIDTH,LOSE_HEIGHT); LCD12864PartUpdate(&display[0],LOSE_X,LOSE_Y,LOSE_WIDTH,LOSE_HEIGHT); SysTick_Wait10ms((GAME_RESTART_DELAY)/10); // wait 2 seconds to start game over Game_Init(); keyPressed = 0; EnableInterrupts(); Music_Play(); } // the following handles the inputs from the user // up button moves link up if ((keyPressed&UP) && gameStarted){ MoveUp(); } // down button moves link down if ((keyPressed&DOWN) && gameStarted){ MoveDown(); } // left button moves link to the left if ((keyPressed&LEFT) && gameStarted){ MoveLeft(); } // right button moves link to the right if ((keyPressed&RIGHT) && gameStarted){ MoveRight(); } // "A" button attacks with sword if ((keyPressed&A) && gameStarted){ PressA(); } // starts the game else if((keyPressed&A) && !gameStarted){ LCD12864ImageDraw(&display[0],&room[0],&room[0],0,0,LCD_WIDTH,LCD_HEIGHT); // draw room LCD12864ImageDraw(&display[0],&room[0],Link.Graphic,Link.Xpos,Link.Ypos,Link.Width,Link.Height); // draw link LCD12864Refresh(&display[0]); // display SysTick_Wait10ms(50); LCD12864ImageDraw(&display[0],&room[0],Boss.Graphic,Boss.Xpos,Boss.Ypos,Boss.Width,Boss.Height); // draw boss LCD12864Refresh(&display[0]); Change_Song(1); LCD12864GameStart(); Timer1A_Enable(); gameStarted = 1; } // "B" button mutes the game music if ((keyPressed&B) && gameStarted){ PressB(); ClearB(); } // updates the screen when Link moves if(keyPressed && gameStarted){ LCD12864ImageDraw(&display[0],&room[0],Link.Graphic,Link.Xpos,Link.Ypos,Link.Width,Link.Height); LCD12864PartUpdate(&display[0],Link.Xpos,Link.Ypos,Link.Width,Link.Height); CheckContact(); SysTick_Wait10ms((LINK_SPEED)/10); // time to wait until next movement } }
void ChartAspectRelation() { int ca[cAspect + 1], co[objMax]; char sz[cchSzDef]; int pcut = 30000000, icut=0, jcut=0, phi, ihi=0, jhi=0, ahi=0, p, i, j, k, count = 0, m; real ip, jp, rPowSum = 0.0; char ignoreT[objMax]; real power2[oNormOpt+1]; PrintHeader(); /* Display chart info */ for (m = 0; m <= cObjOpt; m++) ignoreT[m] = FIgnore(m); for (i = 0; i <= oNormOpt; i++) power2[i] = rObjInf[i]; if (us.nRel == rcTransit) { for (m = 0; m <= cObjOpt; m++) ignoreT[m] = FIgnore2(m); for (i = 0; i <= oNormOpt; i++) power2[i] = rTransitInf[i]; } else { if (us.nRel == rcDual) for (i = 0; i <= oNormOpt; i++) power2[i] = ppower2[i]; if (us.nRel == rcProgress) { for (m = 0; m <= cObjOpt; m++) ignoreT[m] = FIgnore3(m); for (i = 0; i<= oNormOpt; i++) power2[i] = ppower1[i]; } } ClearB((lpbyte)ca, (cAspect + 1)*(int)sizeof(int)); ClearB((lpbyte)co, objMax*(int)sizeof(int)); loop { phi = -1; /* Search for the next most powerful aspect in the aspect grid. */ for (i = 0; i <= cObjOpt; i++) if (!FIgnore(i)) for (j = 0; j <= cObjOpt; j++) if (!FIgnore(j)&& !(FIgnoreS(i)&&FIgnoreS(j))) if ((k = grid->n[i][j])) { ip = FStar(i) ? 2.5 : (power2[i]*rObjInf[i]/13.0); jp = FStar(j) ? 2.5 : (ppower1[j]*rObjInf[j]/13.0); p = (int)(rAspInf[k]*(sqrt)(ip*jp)* (1.0-RAbs((real)(grid->v[i][j]))/3600.0/GetOrb(i, j, k))*500.0); if (us.fParallel) p = p / 4; if ((p < pcut || (p == pcut && (i > icut || (i == icut && j > jcut)))) && p > phi) { ihi = i; jhi = j; phi = p; ahi = k; } } if (phi < 0) /* Exit when no less powerful aspect found. */ break; pcut = phi; icut = ihi; jcut = jhi; count++; /* Display the current aspect. */ #ifdef INTERPRET if (us.fInterpret) { /* Interpret it if -I in effect. */ InterpretAspectRelation(jhi, ihi); continue; } #endif rPowSum += (real)phi/500.0; ca[ahi]++; co[jhi]++; co[ihi]++; sprintf(sz, "%5d: ", count); PrintSz(sz); PrintAspect(jhi, SFromZ(cp1.obj[jhi]), (int)RSgn(cp1.dir[jhi]), ahi, ihi, SFromZ(cp2.obj[ihi]), (int)RSgn(cp2.dir[ihi]), 'A'); k = grid->v[ihi][jhi]; AnsiColor(k < 0 ? kWhite : kLtGray); sprintf(sz, us.fSeconds ?"- orb: %c%d,%02d'%02d\"":"- orb: %c%d:%02d'", us.fAppSep ? (k < 0 ? 'a' : 's') : (k < 0 ? '-' : '+'), abs(k)/3600,(abs(k)%3600)/60 ,abs(k)%60); PrintSz(sz); AnsiColor(kDkGreen); sprintf(sz, " power:%6.2f\n", (real)phi/500.0); PrintSz(sz); AnsiColor(kDefault); } PrintAspectSummary(ca, co, count, rPowSum); }