static void pred_spatial_direct_motion(const H264Context *const h, H264SliceContext *sl, int *mb_type) { int b8_stride = 2; int b4_stride = h->b_stride; int mb_xy = sl->mb_xy, mb_y = sl->mb_y; int mb_type_col[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int8_t *l1ref0, *l1ref1; const int is_b8x8 = IS_8X8(*mb_type); unsigned int sub_mb_type = MB_TYPE_L0L1; int i8, i4; int ref[2]; int mv[2]; int list; assert(sl->ref_list[1][0].reference & 3); await_reference_mb_row(h, &sl->ref_list[1][0], sl->mb_y + !!IS_INTERLACED(*mb_type)); #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \ MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM) /* ref = min(neighbors) */ for (list = 0; list < 2; list++) { int left_ref = sl->ref_cache[list][scan8[0] - 1]; int top_ref = sl->ref_cache[list][scan8[0] - 8]; int refc = sl->ref_cache[list][scan8[0] - 8 + 4]; const int16_t *C = sl->mv_cache[list][scan8[0] - 8 + 4]; if (refc == PART_NOT_AVAILABLE) { refc = sl->ref_cache[list][scan8[0] - 8 - 1]; C = sl->mv_cache[list][scan8[0] - 8 - 1]; } ref[list] = FFMIN3((unsigned)left_ref, (unsigned)top_ref, (unsigned)refc); if (ref[list] >= 0) { /* This is just pred_motion() but with the cases removed that * cannot happen for direct blocks. */ const int16_t *const A = sl->mv_cache[list][scan8[0] - 1]; const int16_t *const B = sl->mv_cache[list][scan8[0] - 8]; int match_count = (left_ref == ref[list]) + (top_ref == ref[list]) + (refc == ref[list]); if (match_count > 1) { // most common mv[list] = pack16to32(mid_pred(A[0], B[0], C[0]), mid_pred(A[1], B[1], C[1])); } else { assert(match_count == 1); if (left_ref == ref[list]) mv[list] = AV_RN32A(A); else if (top_ref == ref[list]) mv[list] = AV_RN32A(B); else mv[list] = AV_RN32A(C); } av_assert2(ref[list] < (sl->ref_count[list] << !!FRAME_MBAFF(h))); } else { int mask = ~(MB_TYPE_L0 << (2 * list)); mv[list] = 0; ref[list] = -1; if (!is_b8x8) *mb_type &= mask; sub_mb_type &= mask; } } if (ref[0] < 0 && ref[1] < 0) { ref[0] = ref[1] = 0; if (!is_b8x8) *mb_type |= MB_TYPE_L0L1; sub_mb_type |= MB_TYPE_L0L1; } if (!(is_b8x8 | mv[0] | mv[1])) { fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1); fill_rectangle(&sl->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4); fill_rectangle(&sl->mv_cache[1][scan8[0]], 4, 4, 8, 0, 4); *mb_type = (*mb_type & ~(MB_TYPE_8x8 | MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_P1L0 | MB_TYPE_P1L1)) | MB_TYPE_16x16 | MB_TYPE_DIRECT2; return; } if (IS_INTERLACED(sl->ref_list[1][0].parent->mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL mb_y = (sl->mb_y & ~1) + sl->col_parity; mb_xy = sl->mb_x + ((sl->mb_y & ~1) + sl->col_parity) * h->mb_stride; b8_stride = 0; } else { mb_y += sl->col_fieldoff; mb_xy += h->mb_stride * sl->col_fieldoff; // non-zero for FL -> FL & differ parity } goto single_col; } else { // AFL/AFR/FR/FL -> AFR/FR if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR mb_y = sl->mb_y & ~1; mb_xy = (sl->mb_y & ~1) * h->mb_stride + sl->mb_x; mb_type_col[0] = sl->ref_list[1][0].parent->mb_type[mb_xy]; mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy + h->mb_stride]; b8_stride = 2 + 4 * h->mb_stride; b4_stride *= 6; if (IS_INTERLACED(mb_type_col[0]) != IS_INTERLACED(mb_type_col[1])) { mb_type_col[0] &= ~MB_TYPE_INTERLACED; mb_type_col[1] &= ~MB_TYPE_INTERLACED; } sub_mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */ if ((mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) && (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) && !is_b8x8) { *mb_type |= MB_TYPE_16x8 | MB_TYPE_DIRECT2; /* B_16x8 */ } else { *mb_type |= MB_TYPE_8x8; } } else { // AFR/FR -> AFR/FR single_col: mb_type_col[0] = mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy]; sub_mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */ if (!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)) { *mb_type |= MB_TYPE_16x16 | MB_TYPE_DIRECT2; /* B_16x16 */ } else if (!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16))) { *mb_type |= MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16)); } else { if (!h->ps.sps->direct_8x8_inference_flag) { /* FIXME: Save sub mb types from previous frames (or derive * from MVs) so we know exactly what block size to use. */ sub_mb_type += (MB_TYPE_8x8 - MB_TYPE_16x16); /* B_SUB_4x4 */ } *mb_type |= MB_TYPE_8x8; } } } await_reference_mb_row(h, &sl->ref_list[1][0], mb_y); l1mv0 = (void*)&sl->ref_list[1][0].parent->motion_val[0][h->mb2b_xy[mb_xy]]; l1mv1 = (void*)&sl->ref_list[1][0].parent->motion_val[1][h->mb2b_xy[mb_xy]]; l1ref0 = &sl->ref_list[1][0].parent->ref_index[0][4 * mb_xy]; l1ref1 = &sl->ref_list[1][0].parent->ref_index[1][4 * mb_xy]; if (!b8_stride) { if (sl->mb_y & 1) { l1ref0 += 2; l1ref1 += 2; l1mv0 += 2 * b4_stride; l1mv1 += 2 * b4_stride; } } if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) { int n = 0; for (i8 = 0; i8 < 4; i8++) { int x8 = i8 & 1; int y8 = i8 >> 1; int xy8 = x8 + y8 * b8_stride; int xy4 = x8 * 3 + y8 * b4_stride; int a, b; if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8])) continue; sl->sub_mb_type[i8] = sub_mb_type; fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, (uint8_t)ref[0], 1); fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, (uint8_t)ref[1], 1); if (!IS_INTRA(mb_type_col[y8]) && !sl->ref_list[1][0].parent->long_ref && ((l1ref0[xy8] == 0 && FFABS(l1mv0[xy4][0]) <= 1 && FFABS(l1mv0[xy4][1]) <= 1) || (l1ref0[xy8] < 0 && l1ref1[xy8] == 0 && FFABS(l1mv1[xy4][0]) <= 1 && FFABS(l1mv1[xy4][1]) <= 1))) { a = b = 0; if (ref[0] > 0) a = mv[0]; if (ref[1] > 0) b = mv[1]; n++; } else { a = mv[0]; b = mv[1]; } fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, a, 4); fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, b, 4); } if (!is_b8x8 && !(n & 3)) *mb_type = (*mb_type & ~(MB_TYPE_8x8 | MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_P1L0 | MB_TYPE_P1L1)) | MB_TYPE_16x16 | MB_TYPE_DIRECT2; } else if (IS_16X16(*mb_type)) {
/** Missions() will draw the future missions among other things * * \param plr Player * \param X screen coord for mission name string * \param Y screen coord for mission name string * \param val mission number * \param bub if set to 0 or 3 the function will not draw stuff */ void Missions(char plr, int X, int Y, int val, char bub) { TRACE5("->Missions(plr, X %d, Y %d, val %d, bub %c)", X, Y, val, bub); memset(Mev, 0x00, sizeof Mev); if (bub == 1 || bub == 3) { PianoKey(val); Bub_Count = 0; // set the initial bub_count ClearDisplay(); fill_rectangle(6, 31, 182, 46, 3); fill_rectangle(80, 25, 175, 30, 3); display::graphics.setForegroundColor(5); draw_string(55, 30, "TYPE: "); draw_number(0, 0, val); display::graphics.setForegroundColor(5); if (V[val].E > 0) { if (F5 > V[val].E && V[val].Z == 1) { DurPri(F5); } else { DurPri(V[val].E); } } else { DurPri(F5); } } else { display::graphics.setForegroundColor(1); } MissionName(val, X, Y, 24); if (bub == 3) { GetMinus(plr); } if (bub == 0 || bub == 3) { return; } MSteps = sOpen("missSteps.dat", "r", FT_DATA); if (fgets(missStep, 1024, MSteps) == NULL) { memset(missStep, 0, sizeof missStep); } while (!feof(MSteps) && ((missStep[0] - 0x30) * 10 + (missStep[1] - 0x30)) != val) { if (fgets(missStep, 1024, MSteps) == NULL) { break; } } fclose(MSteps); int n; for (n = 2; missStep[n] != 'Z'; n++) { switch (missStep[n]) { case 'A': Draw_IJ(B_Mis(++n)); break; case 'B': Draw_IJV(B_Mis(++n)); break; case 'C': OrbOut(B_Mis(n + 1), B_Mis(n + 2), B_Mis(n + 3)); n += 3; break; case 'D': LefEarth(B_Mis(n + 1), B_Mis(n + 2)); n += 2; break; case 'E': OrbIn(B_Mis(n + 1), B_Mis(n + 2), B_Mis(n + 3)); n += 3; break; case 'F': OrbMid(B_Mis(n + 1), B_Mis(n + 2), B_Mis(n + 3), B_Mis(n + 4)); n += 4; break; case 'G': LefOrb(B_Mis(n + 1), B_Mis(n + 2), B_Mis(n + 3), B_Mis(n + 4)); n += 4; break; case 'H': Draw_LowS(B_Mis(n + 1), B_Mis(n + 2), B_Mis(n + 3), B_Mis(n + 4), B_Mis(n + 5), B_Mis(n + 6)); n += 6; break; case 'I': Fly_By(); break; case 'J': VenMarMerc(B_Mis(++n)); break; case 'K': Draw_PQR(); break; case 'L': Draw_PST(); break; case 'M': Draw_GH(B_Mis(n + 1), B_Mis(n + 2)); n += 2; break; case 'N': Q_Patch(); break; case 'O': RghtMoon(B_Mis(n + 1), B_Mis(n + 2)); n += 2; break; case 'P': DrawLunPas(B_Mis(n + 1), B_Mis(n + 2), B_Mis(n + 3), B_Mis(n + 4)); n += 4; break; case 'Q': DrawLefMoon(B_Mis(n + 1), B_Mis(n + 2)); n += 2; break; case 'R': DrawSTUV(B_Mis(n + 1), B_Mis(n + 2), B_Mis(n + 3), B_Mis(n + 4)); n += 4; break; case 'S': Draw_HighS(B_Mis(n + 1), B_Mis(n + 2), B_Mis(n + 3)); n += 3; break; case 'T': DrawMoon(B_Mis(n + 1), B_Mis(n + 2), B_Mis(n + 3), B_Mis(n + 4), B_Mis(n + 5), B_Mis(n + 6), B_Mis(n + 7)); n += 7; break; case 'U': LefGap(B_Mis(++n)); break; case 'V': S_Patch(B_Mis(++n)); break; case 'W': DrawZ(); break; default : break; } } gr_sync(); MissionCodes(plr, MisType, Pad); TRACE1("<-Missions()"); } // end function missions
/* Draws the entire Future Missions display, including the mission- * specific information. Used to initialize the mission selector * interface. * * This relies on the global buffer vh, which must have been created * prior. The future missions button art is loaded into vh by this * function. * * \param plr The player scheduling the mission's design scheme. * \param mis The mission type. * \param pad 0, 1, or 2 depending on which pad is being used. */ void DrawFuture(char plr, int mis, char pad) { FadeOut(2, 10, 0, 0); Load_FUT_BUT(); boost::shared_ptr<display::PalettizedSurface> planets(Filesystem::readImage("images/fmin.img.0.png")); planets->exportPalette(); display::graphics.screen()->clear(); gr_sync(); fill_rectangle(1, 1, 318, 21, 3); fill_rectangle(317, 22, 318, 198, 3); fill_rectangle(1, 197, 316, 198, 3); fill_rectangle(1, 22, 2, 196, 3); OutBox(0, 0, 319, 199); InBox(3, 3, 30, 19); InBox(3, 22, 316, 196); IOBox(242, 3, 315, 19); ShBox(5, 24, 183, 47); ShBox(5, 24, 201, 47); //name box ShBox(5, 74, 41, 82); // RESET ShBox(5, 49, 53, 72); //dur/man ShBox(43, 74, 53, 82); // Duration lock ShBox(80, 74, 90, 82); // Docking lock ShBox(117, 74, 127, 82); // EVA lock ShBox(154, 74, 164, 82); // LM lock ShBox(191, 74, 201, 82); // Joint mission lock ShBox(5, 84, 16, 130); //arrows up ShBox(5, 132, 16, 146); //middle box ShBox(5, 148, 16, 194); // down ShBox(203, 24, 238, 31); // new right boxes // Mission penalty numerical display fill_rectangle(206, 36, 235, 44, 7); ShBox(203, 33, 238, 47); InBox(205, 35, 236, 45); // Mission scroll arrows draw_up_arrow(8, 95); draw_down_arrow(8, 157); // Display mission steps toggle vh->copyTo(display::graphics.legacyScreen(), 140, 5, 5, 132, 15, 146); // Draw the mission specification toggle buttons Toggle(5, 1); draw_Pie(0); OutBox(5, 49, 53, 72); Toggle(1, 1); TogBox(55, 49, 0); Toggle(2, 1); TogBox(92, 49, 0); Toggle(3, 1); TogBox(129, 49, 0); Toggle(4, 1); if (JointFlag == false) { InBox(191, 74, 201, 82); TogBox(166, 49, 1); } else { OutBox(191, 74, 201, 82); TogBox(166, 49, 0); } gr_sync(); Missions(plr, 8, 37, mis, 1); GetMinus(plr); display::graphics.setForegroundColor(5); /* lines of text are 1:8,30 2:8,37 3:8,44 */ switch (pad) { // These used to say Pad 1, 2, 3 -Leon case 0: draw_string(8, 30, "PAD A:"); break; case 1: draw_string(8, 30, "PAD B:"); break; case 2: draw_string(8, 30, "PAD C:"); break; } display::graphics.setForegroundColor(1); draw_string(9, 80, "RESET"); draw_string(258, 13, "CONTINUE"); display::graphics.setForegroundColor(11); if (Data->Season == 0) { draw_string(200, 9, "SPRING"); } else { draw_string(205, 9, "FALL"); } draw_string(206, 16, "19"); draw_number(0, 0, Data->Year); display::graphics.setForegroundColor(1); draw_small_flag(plr, 4, 4); draw_heading(40, 5, "FUTURE MISSIONS", 0, -1); FadeIn(2, 10, 0, 0); return; }
void AstLevel(char plr, char prog, char crew, char ast) { int i, k, man, over = 0, temp, val; char Compat[5], cnt; i = man = Guy(plr, prog, crew, ast); cnt = 0; for (k = 0; k < 5; k++) { Compat[k] = 0; } switch (Data->P[plr].Pool[i].Compat) { case 1: if (Data->P[plr].Pool[i].CL == 2) { Compat[cnt++] = 9; } Compat[cnt++] = 10; Compat[cnt++] = 1; Compat[cnt++] = 2; if (Data->P[plr].Pool[i].CR == 2) { Compat[cnt++] = 3; } break; case 2: if (Data->P[plr].Pool[i].CL == 2) { Compat[cnt++] = 10; } Compat[cnt++] = 1; Compat[cnt++] = 2; Compat[cnt++] = 3; if (Data->P[plr].Pool[i].CR == 2) { Compat[cnt++] = 4; } break; case 3: case 4: case 5: case 6: case 7: case 8: if (Data->P[plr].Pool[i].CL == 2) { Compat[cnt++] = Data->P[plr].Pool[i].Compat - 2; } Compat[cnt++] = Data->P[plr].Pool[i].Compat - 1; Compat[cnt++] = Data->P[plr].Pool[i].Compat; Compat[cnt++] = Data->P[plr].Pool[i].Compat + 1; if (Data->P[plr].Pool[i].CR == 2) { Compat[cnt++] = Data->P[plr].Pool[i].Compat + 2; } break; case 9: if (Data->P[plr].Pool[i].CL == 2) { Compat[cnt++] = 7; } Compat[cnt++] = 8; Compat[cnt++] = 9; Compat[cnt++] = 10; if (Data->P[plr].Pool[i].CR == 2) { Compat[cnt++] = 1; } break; case 10: if (Data->P[plr].Pool[i].CL == 2) { Compat[cnt++] = 8; } Compat[cnt++] = 9; Compat[cnt++] = 10; Compat[cnt++] = 1; if (Data->P[plr].Pool[i].CR == 2) { Compat[cnt++] = 2; } break; } display::LegacySurface local(143, 74); local.copyFrom(display::graphics.legacyScreen(), 94, 38, 236, 111); ShBox(94, 38, 236, 95); InBox(98, 41, 232, 61); fill_rectangle(99, 42, 231, 60, 7 + plr * 3); display::graphics.setForegroundColor(12); draw_string(115, 48, "COMPATIBILITY"); over = 0; val = 0; for (i = 0; i < Data->P[plr].CrewCount[prog][crew]; i++) { if (man != Guy(plr, prog, crew, i)) { temp = 0; for (k = 0; k < cnt; k++) { if (Compat[k] == Data->P[plr].Pool[Guy(plr, prog, crew, i)].Compat) { temp++; } } if ((plr == 1 && Data->Def.Ast2 == 0) || (plr == 0 && Data->Def.Ast1 == 0)) { InBox(111, 66 + 9 * val, 119, 72 + 9 * val); if (temp == 0) { fill_rectangle(112, 67 + 9 * val, 118, 71 + 9 * val, 9); over++; } else { fill_rectangle(112, 67 + 9 * val, 118, 71 + 9 * val, 16); } display::graphics.setForegroundColor(1); draw_string(122, 71 + 9 * val, Data->P[plr].Pool[Guy(plr, prog, crew, i)].Name); } else if (temp == 0) { over++; } val++; } } switch (prog) { case 1: i = 16; break; case 2: i = (over == 1) ? 9 : 16; break; case 3: i = (over == 1) ? 11 : ((over == 2) ? 9 : 16) ; break; case 4: i = (over == 1) ? 11 : ((over == 2) ? 9 : 16) ; break; case 5: i = (over == 1) ? 11 : ((over >= 2) ? 9 : 16) ; break; default: i = 16; break; } // Level 2 Only if ((plr == 1 && Data->Def.Ast2 == 1) || (plr == 0 && Data->Def.Ast1 == 1)) { InBox(111, 66, 119, 72); fill_rectangle(112, 67, 118, 71, i); display::graphics.setForegroundColor(1); draw_string(122, 71, "CREW RELATIONSHIP"); } if ((plr == 1 && Data->Def.Ast2 == 2) || (plr == 0 && Data->Def.Ast1 == 2)) { display::graphics.setForegroundColor(1); draw_string(111, 71, "NO INFO AT THIS LEVEL"); } //fill_rectangle(113,53,119,57,i); // shouldn't be mood display::graphics.setForegroundColor(11); draw_string(115, 57, Data->P[plr].Pool[man].Name); // don't do this for level three draw_string(0, 0, " M: "); draw_number(0, 0, Data->P[plr].Pool[man].Mood); key = 0; if (mousebuttons) { WaitForMouseUp(); } else while (key == 0) { GetMouse(); } local.copyTo(display::graphics.legacyScreen(), 94, 38); }
/** * The main capsule building interface. * * Programs refers to the Manned capsule programs, specifically the * ones where astronauts may be assigned. This has the main control * loop for the capsule building user interface. * * \param plr the country running the program * \param prog the capsule style */ void Programs(char plr, char prog) { int i, max, chk, tst; int now2 = 0, count = 0, grp = 0, BarA = 0; int M[100], CrewCount[8]; char ksel = 0; helpText = "i036"; keyHelpText = "k036"; for (i = 0; i < 100; i++) { M[i] = -1; } if (prog > 4) { max = 4; } else if (prog == 4) { max = 3; } else { max = prog; } music_start(M_PRGMTRG); DrawProgs(plr, prog); Flts(0, 0); for (i = 0; i < ASTRONAUT_CREW_MAX; i++) { CrewCount[i] = Data->P[plr].CrewCount[prog][i]; if (CrewCount[i] == 0) { FltsTxt(i, 8); } if (CrewCount[i] < max && CrewCount[i] != 0) { FltsTxt(i, 9); } if (CrewCount[i] == max) { FltsTxt(i, 1); } } for (i = 0; i < Data->P[plr].AstroCount; i++) { if (Data->P[plr].Pool[i].Assign == prog && Data->P[plr].Pool[i].Crew == 0) { M[count++] = i; } } ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); FadeIn(2, 10, 0, 0); chk = CheckProgram(plr, prog); if (chk == 0) { if (plr == 0) { Help("i113"); } else { Help("i114"); } music_stop(); return; } WaitForMouseUp(); while (1) { key = 0; GetMouse(); for (i = 0; i < 8; i++) { // Right Select Box if (x >= 27 && y >= (131 + i * 8) && x <= 151 && y <= (137 + i * 8) && mousebuttons > 0 && (now2 - BarA + i) <= (count - 1)) { // Left now2 -= BarA; now2 += i; BarA = i; fill_rectangle(26, 129, 153, 195, 0); DispLeft(plr, BarA, count, now2, &M[0]); ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); BarSkill(plr, BarA, now2, &M[0]); WaitForMouseUp(); ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } } if (mousebuttons > 0 || key > 0) { /* Gameplay */ if (((x >= 6 && y >= 130 && x <= 18 && y <= 161 && mousebuttons > 0) || key == UP_ARROW) && count > 0) { /* Lft Up */ InBox(6, 130, 18, 161); for (i = 0; i < 50; i++) { key = 0; GetMouse(); delay(10); if (mousebuttons == 0) { if (BarA == 0) if (now2 > 0) { now2--; fill_rectangle(26, 129, 153, 195, 0); ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } if (BarA > 0) { fill_rectangle(26, 129, 153, 195, 0); BarA--; now2--; ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } i = 51; } } while (mousebuttons == 1 || key == UP_ARROW) { delay(100); if (BarA == 0) if (now2 > 0) { now2--; fill_rectangle(26, 129, 153, 195, 0); ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } if (BarA > 0) { fill_rectangle(26, 129, 153, 195, 0); BarA--; now2--; ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } key = 0; GetMouse(); } OutBox(6, 130, 18, 161); delay(10); } else if (((x >= 6 && y >= 163 && x <= 18 && y <= 194 && mousebuttons > 0) || key == DN_ARROW) && count > 0) { /* Lft Dwn */ InBox(6, 163, 18, 194); for (i = 0; i < 50; i++) { key = 0; GetMouse(); delay(10); if (mousebuttons == 0) { if (BarA == 7) if (now2 < count - 1) { now2++; fill_rectangle(26, 129, 153, 195, 0); ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } if (BarA < 7) if (now2 < count - 1) { fill_rectangle(26, 129, 153, 195, 0); BarA++; now2++; ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } i = 51; } } while (mousebuttons == 1 || key == DN_ARROW) { delay(100); if (BarA == 7) if (now2 < count - 1) { now2++; fill_rectangle(26, 129, 153, 195, 0); ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } if (BarA < 7) if (now2 < count - 1) { fill_rectangle(26, 129, 153, 195, 0); BarA++; now2++; ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } key = 0; GetMouse(); } //WaitForMouseUp(); OutBox(6, 163, 18, 194); } else if (key == K_HOME) { fill_rectangle(26, 129, 153, 195, 0); BarA = 0; now2 = 0; ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } else if (key == K_END) { fill_rectangle(26, 129, 153, 195, 0); BarA = MIN(count - 1, 7); now2 = count - 1; ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); } else if (key == 'S') { // Show Skill ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); BarSkill(plr, BarA, now2, &M[0]); } else if (((x >= 4 && y >= 86 && x <= 12 && y <= 92 && mousebuttons > 0) || key == '1') && CrewCount[grp] >= 1) { /* Display Man 1 */ InBox(4, 86, 12, 92); AstLevel(plr, prog, grp, 0); OutBox(4, 86, 12, 92); } else if (((x >= 4 && y >= 95 && x <= 12 && y <= 101 && mousebuttons > 0) || key == '2') && prog >= 2 && CrewCount[grp] >= 2) { /* Display Man 2 */ InBox(4, 95, 12, 101); AstLevel(plr, prog, grp, 1); OutBox(4, 95, 12, 101); } else if (((x >= 4 && y >= 104 && x <= 12 && y <= 110 && mousebuttons > 0) || key == '3') && prog >= 3 && CrewCount[grp] >= 3) { /* Display Man 3 */ InBox(4, 104, 12, 110); AstLevel(plr, prog, grp, 2); OutBox(4, 104, 12, 110); } else if (((x >= 4 && y >= 113 && x <= 12 && y <= 119 && mousebuttons > 0) || key == '4') && prog >= 5 && CrewCount[grp] >= 4) { /* Display Man 4 */ InBox(4, 113, 12, 119); AstLevel(plr, prog, grp, 3); OutBox(4, 113, 12, 119); } else if (key == 'C') { ClearIt(); ksel = grp; //save old flt crew if (grp == 7) { grp = 0; } else { ++grp; } Flts(ksel, grp); NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); if (key > 0) { delay(150); } } else if (x >= 164 && y >= 139 && x <= 238 && y <= 151 && mousebuttons > 0) { /* Flt Crew I */ ClearIt(); Flts(grp, 0); grp = 0; NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); WaitForMouseUp(); } else if (x >= 164 && y >= 154 && x <= 238 && y <= 166 && mousebuttons > 0) { /* Flt Crew II */ ClearIt(); Flts(grp, 1); grp = 1; NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); WaitForMouseUp(); } else if (x >= 164 && y >= 169 && x <= 238 && y <= 181 && mousebuttons > 0) { /* Flt Crew III */ ClearIt(); Flts(grp, 2); grp = 2; NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); WaitForMouseUp(); } else if (x >= 164 && y >= 184 && x <= 238 && y <= 196 && mousebuttons > 0) { /* Flt Crew IV */ ClearIt(); Flts(grp, 3); grp = 3; NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); WaitForMouseUp(); } else if (x >= 241 && y >= 139 && x <= 315 && y <= 151 && mousebuttons > 0) { /* Flt Crew V */ ClearIt(); Flts(grp, 4); grp = 4; NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); WaitForMouseUp(); } else if (x >= 241 && y >= 154 && x <= 315 && y <= 166 && mousebuttons > 0) { /* Flt Crew VI */ ClearIt(); Flts(grp, 5); grp = 5; NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); WaitForMouseUp(); } else if (x >= 241 && y >= 169 && x <= 315 && y <= 181 && mousebuttons > 0) { /* Flt Crew VII */ ClearIt(); Flts(grp, 6); grp = 6; NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); WaitForMouseUp(); } else if (x >= 241 && y >= 184 && x <= 315 && y <= 196 && mousebuttons > 0) { /* Flt Crew VIII */ ClearIt(); Flts(grp, 7); grp = 7; NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); WaitForMouseUp(); } else if (((x >= 245 && y >= 88 && x <= 314 && y <= 100 && mousebuttons > 0) || key == 'A') && CrewCount[grp] < max) { /* Assign 'Naut */ if (Data->P[plr].Crew[prog][grp][CrewCount[grp]] == 0 && count > 0) { InBox(245, 88, 314, 100); Data->P[plr].Crew[prog][grp][CrewCount[grp]] = M[now2] + 1; AstNames(CrewCount[grp], &Data->P[plr].Pool[M[now2]].Name[0], Data->P[plr].Pool[M[now2]].Mood); Data->P[plr].Pool[M[now2]].Crew = grp + 1; Data->P[plr].Pool[M[now2]].Task = CrewCount[grp]; Data->P[plr].Pool[M[now2]].Unassigned = 1; for (i = now2; i < count; i++) { M[i] = M[i + 1]; } M[i] = -1; count--; if (now2 == count) { if (now2 > 0) { now2--; } if (BarA > 0) { BarA--; } } fill_rectangle(26, 129, 153, 195, 0); ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); CrewCount[grp]++; Data->P[plr].CrewCount[prog][grp] = CrewCount[grp]; if (CrewCount[grp] == max) { FltsTxt(grp, 1); } else { FltsTxt(grp, 9); } NewAstList(plr, prog, Data->P[plr].Crew[prog][grp][0], Data->P[plr].Crew[prog][grp][1], Data->P[plr].Crew[prog][grp][2], Data->P[plr].Crew[prog][grp][3]); WaitForMouseUp(); if (key > 0) { delay(150); } OutBox(245, 88, 314, 100); } /* End outer if */ } else if ((x >= 245 && y >= 106 && x <= 314 && y <= 118 && mousebuttons > 0) || key == 'B') { /* Break Group */ tst = Data->P[plr].Crew[prog][grp][0] - 1; /* If the crew is assigned to a mission, create an alert * that it cannot be broken while the mission is planned. */ if (Data->P[plr].Pool[tst].Prime > 0) { OutBox(245, 106, 314, 118); /* Copy the screen area into a buffer before drawing * the dialog so it can be repainted after the dialog * is dismissed */ display::LegacySurface buffer(170, 131); buffer.copyFrom(display::graphics.legacyScreen(), 75, 43, 244, 173); /* Draw the alert message */ ShBox(75, 43, 244, 173); IOBox(81, 152, 238, 167); InBox(81, 70, 238, 113); fill_rectangle(82, 71, 237, 112, 7 + 3 * plr); display::graphics.setForegroundColor(1); draw_heading(118, 50, "PROBLEM", 0, -1); draw_string(136, 162, "CONTINUE"); display::graphics.setForegroundColor(11); draw_string(88, 80, "FLIGHT CREW "); draw_number(0, 0, grp + 1); draw_string(0, 0, " IS ALREADY"); draw_string(88, 88, "ASSIGNED TO THE "); if (Data->P[plr].Pool[tst].Prime == 4 || Data->P[plr].Pool[tst].Prime == 3) { draw_string(0, 0, "PRIMARY"); } else { draw_string(0, 0, "BACKUP"); } draw_string(88, 96, "CREW OF A CURRENT MISSION:"); draw_string(88, 104, "CANNOT BREAK THIS CREW."); WaitForMouseUp(); i = 1; while (i == 1) { key = 0; GetMouse(); if (mousebuttons > 0 || key > 0) { if ((x >= 83 && y >= 154 && x <= 236 && y <= 165 && mousebuttons != 0) || key == K_ENTER) { InBox(83, 154, 236, 165); WaitForMouseUp(); OutBox(83, 154, 236, 165); /* Closing the alert message. * Redraw the screen behind it from buffer */ buffer.copyTo(display::graphics.legacyScreen(), 75, 43); i = 2; } } } } else if (Data->P[plr].Crew[prog][grp][0] != 0) { InBox(245, 106, 314, 118); while (CrewCount[grp] > 0) { M[count] = Data->P[plr].Crew[prog][grp][CrewCount[grp] - 1] - 1; Data->P[plr].Crew[prog][grp][CrewCount[grp] - 1] = 0; Data->P[plr].Pool[M[count]].Crew = 0; Data->P[plr].Pool[M[count]].Moved = 0; Data->P[plr].Pool[M[now2]].Unassigned = 0; CrewCount[grp]--; count++; } ClearIt(); fill_rectangle(26, 129, 153, 195, 0); FltsTxt(grp, 8); ShBox(26, 130 + BarA * 8, 152, 138 + BarA * 8); DispLeft(plr, BarA, count, now2, &M[0]); for (i = 1; i < 5; i++) { DrawPosition(prog, i); } WaitForMouseUp(); OutBox(245, 106, 314, 118); } } else if ((x >= 245 && y >= 5 && x <= 314 && y <= 17 && mousebuttons > 0) || key == K_ENTER) { /* Exit */ InBox(245, 5, 314, 17); WaitForMouseUp(); if (key > 0) { delay(150); } OutBox(245, 5, 314, 17); delay(10); for (i = 0; i < 8; i++) { if (CrewCount[i] < max) while (CrewCount[i] > 0) { M[count] = Data->P[plr].Crew[prog][i][CrewCount[i] - 1] - 1; Data->P[plr].Crew[prog][i][CrewCount[i] - 1] = 0; Data->P[plr].Pool[M[count]].Crew = 0; Data->P[plr].CrewCount[prog][i] = 0; CrewCount[i]--; count++; } Data->P[plr].CrewCount[prog][i] = CrewCount[i]; } for (i = 0; i < count; i++) { Data->P[plr].Pool[M[i]].Assign = 0; } music_stop(); return; /* Done */ } } } }
void AstNames(int man, char *name, char att) { char col = 0; switch (man) { case 0: fill_rectangle(16, 87, 75, 91, 3); fill_rectangle(5, 87, 11, 91, 3); break; case 1: fill_rectangle(16, 96, 75, 100, 3); fill_rectangle(5, 96, 11, 100, 3); break; case 2: fill_rectangle(16, 105, 75, 109, 3); fill_rectangle(5, 105, 11, 109, 3); break; case 3: fill_rectangle(16, 114, 75, 118, 3); fill_rectangle(5, 114, 11, 118, 3); break; } display::graphics.setForegroundColor(1); if (sex == 1) { display::graphics.setForegroundColor(18); // Show name in blue if 'naut is female } if (retdel > 0) { display::graphics.setForegroundColor(0); // Show name in black if 'naut has announced retirement } if (sex == 1 && retdel > 0) { display::graphics.setForegroundColor(7); // Show name in purple if 'naut is female AND has announced retirement } switch (man) { case 0: draw_string(17, 91, &name[0]); if (missions > 0) { draw_string(0, 0, " ("); draw_number(0, 0, missions); draw_string(0, 0, ")"); } break; case 1: draw_string(17, 100, &name[0]); if (missions > 0) { draw_string(0, 0, " ("); draw_number(0, 0, missions); draw_string(0, 0, ")"); } break; case 2: draw_string(17, 109, &name[0]); if (missions > 0) { draw_string(0, 0, " ("); draw_number(0, 0, missions); draw_string(0, 0, ")"); } break; case 3: draw_string(17, 118, &name[0]); if (missions > 0) { draw_string(0, 0, " ("); draw_number(0, 0, missions); draw_string(0, 0, ")"); } break; } if (att >= 65) { col = 16; } if (att < 65 && att >= 40) { col = 11; } if (att < 40 && att >= 20) { col = 8; } if (att < 20) { col = 0; } if (att == 0) { col = 3; } // if (retdel>0) col=7; switch (man) { case 0: fill_rectangle(5, 87, 11, 91, col); break; case 1: fill_rectangle(5, 96, 11, 100, col); break; case 2: fill_rectangle(5, 105, 11, 109, col); break; case 3: fill_rectangle(5, 114, 11, 118, col); break; } }
void DrawProgs(char plr, char prog) { int i, j, Name[30]; strcpy((char *)Name, Data->P[plr].Manned[prog - 1].Name); strcat((char *)Name, " PROGRAM"); FadeOut(2, 10, 0, 0); display::graphics.screen()->clear(); display::graphics.setForegroundColor(1); ShBox(0, 0, 319, 22); ShBox(0, 24, 319, 81); ShBox(0, 83, 319, 123); ShBox(0, 125, 158, 199); ShBox(161, 125, 319, 199); fill_rectangle(25, 129, 153, 195, 0); fill_rectangle(5, 129, 19, 195, 0); ShBox(6, 130, 18, 161); ShBox(6, 163, 18, 194); IOBox(243, 86, 316, 102); IOBox(243, 104, 316, 120); IOBox(243, 3, 316, 19); InBox(4, 128, 20, 196); InBox(24, 128, 154, 196); InBox(60, 27, 141, 78); InBox(3, 3, 30, 19); draw_up_arrow(9, 133); draw_down_arrow(9, 166); { char filename[128]; snprintf(filename, sizeof(filename), "images/aprog.%d.%d.png", plr, prog); boost::shared_ptr<display::PalettizedSurface> image(Filesystem::readImage(filename)); image->exportPalette(); display::graphics.screen()->draw(image, 61, 28); } for (j = 0; j < 2; j++) { for (i = 0; i < 4; i++) { ShBox(164 + 77 * j, 139 + i * 15, 238 + 77 * j, 151 + i * 15); } } ShBox(4, 86, 12, 92); if (prog >= 2) { ShBox(4, 95, 12, 101); } if (prog >= 3) { ShBox(4, 104, 12, 110); } if (prog == 5) { ShBox(4, 113, 12, 119); } draw_small_flag(plr, 4, 4); display::graphics.setForegroundColor(9); draw_string(250, 96, "A"); display::graphics.setForegroundColor(1); draw_string(0, 0, "SSIGN CREW"); display::graphics.setForegroundColor(9); draw_string(252, 114, "B"); display::graphics.setForegroundColor(1); draw_string(0, 0, "REAK CREW"); draw_string(258, 13, "CONTINUE"); display::graphics.setForegroundColor(5); draw_string(183, 133, "FLIGHT "); display::graphics.setForegroundColor(9); draw_string(0, 0, "C"); display::graphics.setForegroundColor(5); draw_string(0, 0, "REW SELECTION"); display::graphics.setForegroundColor(7); draw_string(152, 35, &Data->P[plr].Manned[prog - 1].Name[0]); display::graphics.setForegroundColor(9); if (prog == 1) { draw_string(152, 43, "ONE"); } if (prog == 2) { draw_string(152, 43, "TWO"); } if (prog == 3 || prog == 4) { draw_string(152, 43, "THREE"); } if (prog == 5) { draw_string(152, 43, "FOUR"); } draw_string(0, 0, "-PERSON CAPACITY"); display::graphics.setForegroundColor(7); draw_string(152, 51, "SAFETY FACTOR: "); display::graphics.setForegroundColor(11); draw_number(0, 0, Data->P[plr].Manned[prog - 1].Safety); draw_string(0, 0, " %"); display::graphics.setForegroundColor(7); draw_string(152, 59, "UNIT WEIGHT: "); display::graphics.setForegroundColor(11); draw_number(0, 0, Data->P[plr].Manned[prog - 1].UnitWeight); display::graphics.setForegroundColor(7); draw_string(152, 67, "MAX DURATION: "); display::graphics.setForegroundColor(11); draw_number(0, 0, Data->P[plr].Manned[prog - 1].Duration); draw_string(0, 0, " DAYS (LVL "); if (prog == 1) { draw_string(0, 0, "B)"); } if (prog == 2) { draw_string(0, 0, "E)"); } if (prog == 3 || prog == 5) { draw_string(0, 0, "F)"); } if (prog == 4) { draw_string(0, 0, "D)"); } display::graphics.setForegroundColor(7); draw_string(152, 75, "AVOID FAILURE: "); display::graphics.setForegroundColor(11); if (Data->P[plr].Manned[prog - 1].SaveCard > 0) { draw_string(0, 0, "YES"); } else { draw_string(0, 0, "NO"); } display::graphics.setForegroundColor(1); draw_heading(40, 5, (char *)Name, 0, -1); return; }
/** * Called after the input is resolved - compute based on input variables and current state and set output variables. */ void process(State* state, InputParams* src, OutputParams* dest) { draw_voltage(state->x10, state->x11, state->lastVoltage1, src->analog0); //Draw three voltage bars. //state->runningTotal = (state->runningTotal + src->analog1) / 2; //draw_voltage(state->x11, state->x21, 3.3, state->runningTotal); draw_voltage(state->x11, state->x21, state->lastVoltage2, src->analog1); draw_voltage(state->x21, state->x31, state->lastVoltage3, src->analog2); state->lastVoltage1 = src->analog0; //Store last voltages. To prevent flickering. state->lastVoltage2 = src->analog1; //Not strictly necessary. Example usage of state. state->lastVoltage3 = src->analog2; if(!src->digit0) { fill_rectangle(state->r2, RED); //Draw Square } else { fill_rectangle(state->r2, BLACK); //Clear Square } if(!src->digit1) { fill_rectangle(state->r3, GREEN); } else { fill_rectangle(state->r3, BLACK); } if(!src->digit2) { fill_rectangle(state->r4, BLUE); } else { fill_rectangle(state->r4, BLACK); } dest->digit0 = !(src->digit0 & src->digit1); //Simple digital output function dest->digit1 = !(src->digit0 | src->digit1); dest->digit2 = !(src->digit0 ^ src->digit1); if(dest->digit0) { fill_rectangle(state->r5, RED); //Draw Square } else { fill_rectangle(state->r5, BLACK); //Clear Square } if(dest->digit1) { fill_rectangle(state->r6, GREEN); } else { fill_rectangle(state->r6, BLACK); } if(dest->digit2) { fill_rectangle(state->r7, BLUE); } else { fill_rectangle(state->r7, BLACK); } }
static cell AMX_NATIVE_CALL amx_fill_rectangle(AMX *amx, const cell *params) { // fill_rectangle(x, y, w, h, Color: color); fill_rectangle(params[1], params[2], params[3], params[4], params[5]); return 0; }
/* Remplit un rectangle dont les extremites d'une de ses diagonales sont (x1, y1) et (x2, y2) */ void RectanglePlein(int x1, int y1, int x2, int y2) { fill_rectangle(fenetreCourante, x1, y1, x2, y2); }
static av_noinline void FUNC(hl_decode_mb)(const H264Context *h, H264SliceContext *sl) { const int mb_x = sl->mb_x; const int mb_y = sl->mb_y; const int mb_xy = sl->mb_xy; const int mb_type = h->cur_pic.mb_type[mb_xy]; uint8_t *dest_y, *dest_cb, *dest_cr; int linesize, uvlinesize /*dct_offset*/; int i, j; const int *block_offset = &h->block_offset[0]; const int transform_bypass = !SIMPLE && (sl->qscale == 0 && h->sps.transform_bypass); /* is_h264 should always be true if SVQ3 is disabled. */ const int is_h264 = !CONFIG_SVQ3_DECODER || SIMPLE || h->avctx->codec_id == AV_CODEC_ID_H264; void (*idct_add)(uint8_t *dst, int16_t *block, int stride); const int block_h = 16 >> h->chroma_y_shift; const int chroma422 = CHROMA422(h); dest_y = h->cur_pic.f.data[0] + ((mb_x << PIXEL_SHIFT) + mb_y * sl->linesize) * 16; dest_cb = h->cur_pic.f.data[1] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * sl->uvlinesize * block_h; dest_cr = h->cur_pic.f.data[2] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * sl->uvlinesize * block_h; h->vdsp.prefetch(dest_y + (sl->mb_x & 3) * 4 * sl->linesize + (64 << PIXEL_SHIFT), sl->linesize, 4); h->vdsp.prefetch(dest_cb + (sl->mb_x & 7) * sl->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2); h->list_counts[mb_xy] = sl->list_count; if (!SIMPLE && MB_FIELD(sl)) { linesize = sl->mb_linesize = sl->linesize * 2; uvlinesize = sl->mb_uvlinesize = sl->uvlinesize * 2; block_offset = &h->block_offset[48]; if (mb_y & 1) { // FIXME move out of this function? dest_y -= sl->linesize * 15; dest_cb -= sl->uvlinesize * (block_h - 1); dest_cr -= sl->uvlinesize * (block_h - 1); } if (FRAME_MBAFF(h)) { int list; for (list = 0; list < sl->list_count; list++) { if (!USES_LIST(mb_type, list)) continue; if (IS_16X16(mb_type)) { int8_t *ref = &sl->ref_cache[list][scan8[0]]; fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (sl->mb_y & 1), 1); } else { for (i = 0; i < 16; i += 4) { int ref = sl->ref_cache[list][scan8[i]]; if (ref >= 0) fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2, 8, (16 + ref) ^ (sl->mb_y & 1), 1); } } } } } else { linesize = sl->mb_linesize = sl->linesize; uvlinesize = sl->mb_uvlinesize = sl->uvlinesize; // dct_offset = s->linesize * 16; } if (!SIMPLE && IS_INTRA_PCM(mb_type)) { if (PIXEL_SHIFT) { const int bit_depth = h->sps.bit_depth_luma; int j; GetBitContext gb; init_get_bits(&gb, sl->intra_pcm_ptr, ff_h264_mb_sizes[h->sps.chroma_format_idc] * bit_depth); for (i = 0; i < 16; i++) { uint16_t *tmp_y = (uint16_t *)(dest_y + i * linesize); for (j = 0; j < 16; j++) tmp_y[j] = get_bits(&gb, bit_depth); } if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { if (!h->sps.chroma_format_idc) { for (i = 0; i < block_h; i++) { uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cb[j] = 1 << (bit_depth - 1); } for (i = 0; i < block_h; i++) { uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cr[j] = 1 << (bit_depth - 1); } } else { for (i = 0; i < block_h; i++) { uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cb[j] = get_bits(&gb, bit_depth); } for (i = 0; i < block_h; i++) { uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize); for (j = 0; j < 8; j++) tmp_cr[j] = get_bits(&gb, bit_depth); } } } } else { for (i = 0; i < 16; i++) memcpy(dest_y + i * linesize, sl->intra_pcm_ptr + i * 16, 16); if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { if (!h->sps.chroma_format_idc) { for (i = 0; i < block_h; i++) { memset(dest_cb + i * uvlinesize, 128, 8); memset(dest_cr + i * uvlinesize, 128, 8); } } else { const uint8_t *src_cb = sl->intra_pcm_ptr + 256; const uint8_t *src_cr = sl->intra_pcm_ptr + 256 + block_h * 8; for (i = 0; i < block_h; i++) { memcpy(dest_cb + i * uvlinesize, src_cb + i * 8, 8); memcpy(dest_cr + i * uvlinesize, src_cr + i * 8, 8); } } } } } else { if (IS_INTRA(mb_type)) { if (sl->deblocking_filter) xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, 0, SIMPLE, PIXEL_SHIFT); if (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) { h->hpc.pred8x8[sl->chroma_pred_mode](dest_cb, uvlinesize); h->hpc.pred8x8[sl->chroma_pred_mode](dest_cr, uvlinesize); } hl_decode_mb_predict_luma(h, sl, mb_type, is_h264, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest_y, 0); if (sl->deblocking_filter) xchg_mb_border(h, sl, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, 0, SIMPLE, PIXEL_SHIFT); } else if (is_h264) { if (chroma422) { FUNC(hl_motion_422)(h, sl, dest_y, dest_cb, dest_cr, h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab, h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab, h->h264dsp.weight_h264_pixels_tab, h->h264dsp.biweight_h264_pixels_tab); } else { FUNC(hl_motion_420)(h, sl, dest_y, dest_cb, dest_cr, h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab, h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab, h->h264dsp.weight_h264_pixels_tab, h->h264dsp.biweight_h264_pixels_tab); } } hl_decode_mb_idct_luma(h, sl, mb_type, is_h264, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest_y, 0); if ((SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) && (sl->cbp & 0x30)) { uint8_t *dest[2] = { dest_cb, dest_cr }; if (transform_bypass) { if (IS_INTRA(mb_type) && h->sps.profile_idc == 244 && (sl->chroma_pred_mode == VERT_PRED8x8 || sl->chroma_pred_mode == HOR_PRED8x8)) { h->hpc.pred8x8_add[sl->chroma_pred_mode](dest[0], block_offset + 16, sl->mb + (16 * 16 * 1 << PIXEL_SHIFT), uvlinesize); h->hpc.pred8x8_add[sl->chroma_pred_mode](dest[1], block_offset + 32, sl->mb + (16 * 16 * 2 << PIXEL_SHIFT), uvlinesize); } else { idct_add = h->h264dsp.h264_add_pixels4_clear; for (j = 1; j < 3; j++) { for (i = j * 16; i < j * 16 + 4; i++) if (sl->non_zero_count_cache[scan8[i]] || dctcoef_get(sl->mb, PIXEL_SHIFT, i * 16)) idct_add(dest[j - 1] + block_offset[i], sl->mb + (i * 16 << PIXEL_SHIFT), uvlinesize); if (chroma422) { for (i = j * 16 + 4; i < j * 16 + 8; i++) if (sl->non_zero_count_cache[scan8[i + 4]] || dctcoef_get(sl->mb, PIXEL_SHIFT, i * 16)) idct_add(dest[j - 1] + block_offset[i + 4], sl->mb + (i * 16 << PIXEL_SHIFT), uvlinesize); } } } } else { if (is_h264) { int qp[2]; if (chroma422) { qp[0] = sl->chroma_qp[0] + 3; qp[1] = sl->chroma_qp[1] + 3; } else { qp[0] = sl->chroma_qp[0]; qp[1] = sl->chroma_qp[1]; } if (sl->non_zero_count_cache[scan8[CHROMA_DC_BLOCK_INDEX + 0]]) h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + (16 * 16 * 1 << PIXEL_SHIFT), h->dequant4_coeff[IS_INTRA(mb_type) ? 1 : 4][qp[0]][0]); if (sl->non_zero_count_cache[scan8[CHROMA_DC_BLOCK_INDEX + 1]]) h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + (16 * 16 * 2 << PIXEL_SHIFT), h->dequant4_coeff[IS_INTRA(mb_type) ? 2 : 5][qp[1]][0]); h->h264dsp.h264_idct_add8(dest, block_offset, sl->mb, uvlinesize, sl->non_zero_count_cache); } else if (CONFIG_SVQ3_DECODER) { h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + 16 * 16 * 1, h->dequant4_coeff[IS_INTRA(mb_type) ? 1 : 4][sl->chroma_qp[0]][0]); h->h264dsp.h264_chroma_dc_dequant_idct(sl->mb + 16 * 16 * 2, h->dequant4_coeff[IS_INTRA(mb_type) ? 2 : 5][sl->chroma_qp[1]][0]); for (j = 1; j < 3; j++) { for (i = j * 16; i < j * 16 + 4; i++) if (sl->non_zero_count_cache[scan8[i]] || sl->mb[i * 16]) { uint8_t *const ptr = dest[j - 1] + block_offset[i]; ff_svq3_add_idct_c(ptr, sl->mb + i * 16, uvlinesize, ff_h264_chroma_qp[0][sl->qscale + 12] - 12, 2); } } } } } } }
static av_noinline void FUNC(hl_decode_mb_444)(const H264Context *h, H264SliceContext *sl) { const int mb_x = sl->mb_x; const int mb_y = sl->mb_y; const int mb_xy = sl->mb_xy; const int mb_type = h->cur_pic.mb_type[mb_xy]; uint8_t *dest[3]; int linesize; int i, j, p; const int *block_offset = &h->block_offset[0]; const int transform_bypass = !SIMPLE && (sl->qscale == 0 && h->sps.transform_bypass); const int plane_count = (SIMPLE || !CONFIG_GRAY || !(h->flags & CODEC_FLAG_GRAY)) ? 3 : 1; for (p = 0; p < plane_count; p++) { dest[p] = h->cur_pic.f.data[p] + ((mb_x << PIXEL_SHIFT) + mb_y * sl->linesize) * 16; h->vdsp.prefetch(dest[p] + (sl->mb_x & 3) * 4 * sl->linesize + (64 << PIXEL_SHIFT), sl->linesize, 4); } h->list_counts[mb_xy] = sl->list_count; if (!SIMPLE && MB_FIELD(sl)) { linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize * 2; block_offset = &h->block_offset[48]; if (mb_y & 1) // FIXME move out of this function? for (p = 0; p < 3; p++) dest[p] -= sl->linesize * 15; if (FRAME_MBAFF(h)) { int list; for (list = 0; list < sl->list_count; list++) { if (!USES_LIST(mb_type, list)) continue; if (IS_16X16(mb_type)) { int8_t *ref = &sl->ref_cache[list][scan8[0]]; fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (sl->mb_y & 1), 1); } else { for (i = 0; i < 16; i += 4) { int ref = sl->ref_cache[list][scan8[i]]; if (ref >= 0) fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2, 8, (16 + ref) ^ (sl->mb_y & 1), 1); } } } } } else { linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize; } if (!SIMPLE && IS_INTRA_PCM(mb_type)) { if (PIXEL_SHIFT) { const int bit_depth = h->sps.bit_depth_luma; GetBitContext gb; init_get_bits(&gb, sl->intra_pcm_ptr, 768 * bit_depth); for (p = 0; p < plane_count; p++) for (i = 0; i < 16; i++) { uint16_t *tmp = (uint16_t *)(dest[p] + i * linesize); for (j = 0; j < 16; j++) tmp[j] = get_bits(&gb, bit_depth); } } else { for (p = 0; p < plane_count; p++) for (i = 0; i < 16; i++) memcpy(dest[p] + i * linesize, sl->intra_pcm_ptr + p * 256 + i * 16, 16); } } else { if (IS_INTRA(mb_type)) { if (sl->deblocking_filter) xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize, linesize, 1, 1, SIMPLE, PIXEL_SHIFT); for (p = 0; p < plane_count; p++) hl_decode_mb_predict_luma(h, sl, mb_type, 1, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest[p], p); if (sl->deblocking_filter) xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize, linesize, 0, 1, SIMPLE, PIXEL_SHIFT); } else { FUNC(hl_motion_444)(h, sl, dest[0], dest[1], dest[2], h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab, h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab, h->h264dsp.weight_h264_pixels_tab, h->h264dsp.biweight_h264_pixels_tab); } for (p = 0; p < plane_count; p++) hl_decode_mb_idct_luma(h, sl, mb_type, 1, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest[p], p); } }
/* * Main function to run one tick of the game */ int run_game() { cli(); /* Movement phase */ if(game_state == 1) { /* Move the reticule based on readings from the rotary encoder */ int16_t newRX = (playersX[current_player] + (RETICULE_DISTANCE * ml_cos(position))/100); int16_t newRY = (playersY[current_player] + (RETICULE_DISTANCE * ml_sin(position))/100); rectangle reticuleOld = {reticuleX - reticule_SPR->width / 2, reticuleX + reticule_SPR->width / 2 - 1, reticuleY - reticule_SPR->height / 2, reticuleY + reticule_SPR->height / 2 - 1}; draw_background(level_map, SILVER, reticuleOld, HEIGHT_NO_UI, WIDTH); //fill_rectangle(reticuleOld, BLACK); if(newRX >= 0 && newRX < WIDTH && newRY >= 0 && newRY < HEIGHT) fill_sprite(reticule_SPR, newRX, newRY, HEIGHT_NO_UI, WIDTH); reticuleX = newRX; reticuleY = newRY; /* Read firing input */ if (get_switch_long(_BV(SWC))) { game_state = 3; return 0; } /* Read directional input.*/ if (get_switch_rpt(_BV(SWE))) { direction = 4; free_sprite(player_SPR); player_SPR = botright(current_player); } else if (get_switch_rpt(_BV(SWW))) { direction = -4; free_sprite(player_SPR); player_SPR = botleft(current_player); } else { direction = 0; return 0; } /* Move the player */ int16_t newX = playersX[current_player] + direction; int16_t newY = ml_min(level_map[newX - PLAYER_WIDTH], level_map[newX + PLAYER_WIDTH - 1]) - PLAYER_HEIGHT; int8_t i; int8_t player_collision = 0; for(i = 0; i < players; i++) { if(players_HP[i] != 0 && i != current_player && newX >= playersX[i] - PLAYER_WIDTH && newX <= playersX[i] + PLAYER_WIDTH - 1) { player_collision = 1; break; } } /* Cancel movement if trying to climb to high or off the sides of the screen */ if(player_collision || playersY[current_player] - newY > MAX_CLIMB_HEIGHT || newX <= PLAYER_WIDTH || newX + PLAYER_WIDTH > WIDTH) { /* DEBUGGING prints: */ //display_string_xy("Error\n", 10, 10); //ml_printf("Cannot move there... (%u,%u) to (%u,%u)", playersX[0], playersY[0], newX, newY); return 0; } rectangle playerOld = {playersX[current_player] - PLAYER_WIDTH, playersX[current_player] + PLAYER_WIDTH - 1, playersY[current_player] - PLAYER_HEIGHT, playersY[current_player] + PLAYER_HEIGHT - 1}; fill_rectangle(playerOld, BLACK); fill_sprite(player_SPR, newX, newY, HEIGHT_NO_UI, WIDTH); playersX[current_player] = newX; playersY[current_player] = newY; } /* Projectile phase (missile in the air) */ else if(game_state == 2) { /* Find the new position of the projectile */ int16_t newX = projectileX + proVelX/1000; int16_t newY = projectileY + proVelY/1000; rectangle projectileOld = {projectileX, projectileX, projectileY, projectileY}; fill_rectangle(projectileOld, BLACK); /* End turn if projectile goes off the sides of the level */ if(newX < 0 || newX > WIDTH) { start_turn(); return 0; } /* If the new position is in the ground, EXPLODE! * (Also, if off the bottom of the level) */ if(newY >= level_map[newX] || newY > HEIGHT_NO_UI) { int i; for(i = -EXPLOSION_RADIUS; i <= EXPLOSION_RADIUS; i++) { /* Make sure that terrain is on screen */ if(newX + i >= 0 && newX + i < WIDTH) { uint16_t new_ground_level = newY + ml_sqrt(EXPLOSION_RADIUS * EXPLOSION_RADIUS - i * i); if(new_ground_level >= HEIGHT_NO_UI) level_map[newX + i] = HEIGHT_NO_UI - 1; //Clamp to bottom of level else if(new_ground_level > level_map[newX + i]) //Don't raise the ground level! level_map[newX + i] = new_ground_level; } } draw_level(level_map, SILVER, newX - EXPLOSION_RADIUS, newX + EXPLOSION_RADIUS); /* Check players for damage + redraw them */ for(i = 0; i < players; i++) { int16_t deltaX = playersX[i] - newX; int16_t deltaY = playersY[i] - newY; int16_t distance = ml_sqrt(deltaX * deltaX + deltaY * deltaY); if(distance < BLAST_RADIUS) { int16_t damage = ml_clamp(0, players_HP[i], MAX_EXPLOSION_DAMAGE - (distance * MAX_EXPLOSION_DAMAGE / BLAST_RADIUS)); players_HP[i] -= damage; } rectangle playerOld = {playersX[i] - PLAYER_WIDTH, playersX[i] + PLAYER_WIDTH - 1, playersY[i] - PLAYER_HEIGHT, playersY[i] + PLAYER_HEIGHT - 1}; fill_rectangle(playerOld, BLACK); /* If the player is still alive, redraw them */ if(players_HP[i] != 0) { free_sprite(player_SPR); player_SPR = botleft(i); playersY[i] = ml_min(level_map[playersX[i] - PLAYER_WIDTH], level_map[playersX[i] + PLAYER_WIDTH - 1]) - PLAYER_HEIGHT; fill_sprite(player_SPR, playersX[i], playersY[i], HEIGHT_NO_UI, WIDTH); } } start_turn(); return 0; } rectangle projectileNew = {newX, newX, newY, newY}; /* Continue turn if off top of level, but only draw if projectile onscreen */ if(newY >= 0) { fill_rectangle(projectileNew, RED); } projectileX = newX; projectileY = newY; /* Apply gravity and wind */ proVelY += 500; proVelX += (wind_velocity - 10) * 50; } /* Charging phase */ else if(game_state == 3) { /* Increase the launch speed while the fire button is held */ if (get_switch_state(_BV(SWC))) { launch_speed++; rectangle bar = {POWER_BAR_START, POWER_BAR_START + launch_speed, 231, 236}; fill_rectangle(bar, WHITE); /* Fire once max power is reached */ if(launch_speed == 100) fire_projectile(); } else { fire_projectile(); } } /* Menu phase */ else if(game_state == 4) { if (get_switch_press(_BV(SWE))) { if(players == 4) players = 2; else players++; } else if (get_switch_press(_BV(SWW))) { if(players == 2) players = 4; else players--; } ml_printf_at("< %u Players >", 5, 115, players); if (get_switch_long(_BV(SWC))) { start_game(); } } /* End game phase */ else if(game_state == 5) { if (get_switch_long(_BV(SWC))) { start_menu(); } } sei(); return 0; }
/* * Checks to see if there are enough alive players to continue the game * If so, control switches to the next player */ void start_turn() { /* Update the HP UI */ draw_HP_UI(); /* Reset the power bar */ launch_speed = 0; fill_rectangle(power_empty, BLACK); /* If only one player remains, declare them winner. */ uint8_t i; uint8_t player_left; //Record last player left (meaningless if more than 1 survivor) uint8_t players_alive = 0; for(i = 0; i < players; i++) { if(players_HP[i] != 0) { players_alive++; player_left = i; } } if(players_alive == 1) { switch(player_left) { case 0: display_color(BLUE, BLACK); ml_printf_at("To the victor, the spoils! BLUE WINS!", 5, 20); break; case 1: display_color(RED, BLACK); ml_printf_at("And the win goes to RED! Congratulations!", 5, 20); break; case 2: display_color(YELLOW, BLACK); ml_printf_at("Who's the best? YELLOW's the best!", 5, 20); break; default: display_color(GREEN, BLACK); ml_printf_at("Looks like the others are GREEN with envy! (GREEN WINS)", 5, 20); break; } end_game(); return; } else if(players_alive == 0) { display_color(WHITE, BLACK); ml_printf_at("Oh dear, it looks like a DRAW!", 5, 20); end_game(); return; } /* Rotate through the players */ current_player = (current_player + 1) % players; while(players_HP[current_player] == 0) { current_player = (current_player + 1) % players; } /* Re-colour the reticule for the current player */ free_sprite(reticule_SPR); reticule_SPR = reticule(current_player); /* Change to movement phase */ game_state = 1; /* Generate a random(ish) wind for the turn */ wind_velocity = rand() % 21; rectangle *wind_bar = malloc(sizeof(rectangle)); uint16_t wind_colour; fill_rectangle(wind_empty, BLACK); if(wind_velocity < 10) { wind_bar->left = WIND_BAR_START + wind_velocity * 10; wind_bar->right = WIND_BAR_END; wind_bar->top = 231; wind_bar->bottom = 236; wind_colour = RED; } else if (wind_velocity > 10) { wind_bar->left = WIND_BAR_START; wind_bar->right = WIND_BAR_START + (wind_velocity - 10) * 10; wind_bar->top = 231; wind_bar->bottom = 236; wind_colour = BLUE; } else { free(wind_bar); return; } fill_rectangle(*wind_bar, wind_colour); free(wind_bar); }