const u8 *GetLandmarkName(u8 mapSection, u8 id, u8 count) { const struct Landmark *const *landmarks = GetLandmarks(mapSection, id); if (!landmarks) return NULL; while (1) { const struct Landmark *landmark = *landmarks; if (landmark->flag == 0xFFFF || FlagGet(landmark->flag) == TRUE) { if (count == 0) break; else count--; } landmarks++; if (!*landmarks) return NULL; } return (*landmarks)->name; }
void debug_sub_8122080(void) { if (gMapHeader.cave == 1 && !FlagGet(FLAG_SYS_USE_FLASH)) sub_810CBFC(); else ScriptContext2_Disable(); }
bool8 SetUpFieldMove_Flash(void) { if (gMapHeader.cave == TRUE && !FlagGet(FLAG_SYS_USE_FLASH)) { gFieldCallback = FieldCallback_PrepareFadeInFromMenu; gPostMenuFieldCallback = sub_810CBFC; return TRUE; } return FALSE; }
bool32 HasAtLeastFiveBadges(void) { int badgeCount = 0; u32 i; for (i = 0; i < 8; i++) { if (FlagGet(sBadgeFlags[i]) == TRUE) { badgeCount++; if (badgeCount >= 5) return TRUE; } } return FALSE; }
/* * Call this routine to tell the watchdog that the flag * owner has run. */ void WatchdogNotify( INDEX index ) { FLAG flag; #ifdef DEBUG TIME time; #endif //Ensure that we are using a valid flag. ASSERT( index <= FLAG_MAX_INDEX ); //find the bit we want to flip. flag = FlagGetBit( index ); IsrDisable(IRQ_LEVEL_WATCHDOG); //Assert that this flag is present in the desired mask. ASSERT(FlagGet(flag, WatchdogDesiredMask)); #ifdef DEBUG time = TimeGet(); WatchdogLastUpdatedTime = time; #endif FlagOn( WatchdogCurMask, flag ); //check to see if all of the players have shown up. if ( FlagsEqual(WatchdogCurMask, WatchdogDesiredMask) ) { //We have flipped all the flags required. //So lets pet the watchdog. HalPetWatchdog(Timeout); //Now lets clear the mask because we need to //restart our checking. WatchdogCurMask = FLAG_NONE; #ifdef DEBUG WatchdogLastClearedTime = time; #endif } IsrEnable(IRQ_LEVEL_WATCHDOG); }
u8 HasTrainerAlreadyBeenFought(u16 flag) { return FlagGet(TRAINER_FLAG_START + flag); }
u8 ScrSpecial_HasTrainerBeenFought(void) { return FlagGet(CurrentOpponentTrainerFlag()); }
bool32 GetTrainerFlagFromScriptPointer(u8 *data) { u32 flag = TrainerBattleLoadArg16(data + 2); return FlagGet(TRAINER_FLAG_START + flag); }
bool32 GetSafariZoneFlag(void) { return FlagGet(SYS_SAFARI_MODE); }
void Indep(void) { int Count, DRow, DCol; int Found, R, C; double RowDist, RowDistSq, ColDist; struct History history; G_debug(2, "indep()"); Count = 0; Found = 0; while (CellCount > 0) { G_debug(3, "(CellCount):%d", CellCount); G_debug(3, "(Count):%d", Count); DRow = DoNext[Count].R; DCol = DoNext[Count++].C; if (0 != FlagGet(Cells, DRow, DCol)) { /* FLAG_SET( Out, DRow, DCol); */ Out[DRow][DCol] = ++Found; for (R = DRow; R < Rs; R++) { RowDist = NS * (R - DRow); if (RowDist > MaxDistSq) { R = Rs; } else { RowDistSq = RowDist * RowDist; for (C = DCol; C < Cs; C++) { ColDist = EW * (C - DCol); G_debug(3, "(RowDistSq):%.12lf", RowDistSq); G_debug(3, "(ColDist):%.12lf", ColDist); G_debug(3, "(MaxDistSq):%.12lf", MaxDistSq); if (MaxDistSq >= RowDistSq + ColDist * ColDist) { if (0 != FlagGet(Cells, R, C)) { G_debug(2, "unset()"); FLAG_UNSET(Cells, R, C); CellCount--; } } else { C = Cs; } } } } G_debug(2, "it1()"); for (R = DRow - 1; R >= 0; R--) { RowDist = NS * (DRow - R); if (RowDist > MaxDistSq) { R = 0; } else { RowDistSq = RowDist * RowDist; for (C = DCol; C < Cs; C++) { ColDist = EW * (C - DCol); if (MaxDistSq >= RowDistSq + ColDist * ColDist) { if (0 != FlagGet(Cells, R, C)) { G_debug(2, "unset()"); FLAG_UNSET(Cells, R, C); CellCount--; } } else { C = Cs; } } } } G_debug(2, "it2()"); for (R = DRow; R < Rs; R++) { RowDist = NS * (R - DRow); if (RowDist > MaxDistSq) { R = Rs; } else { RowDistSq = RowDist * RowDist; for (C = DCol - 1; C >= 0; C--) { ColDist = EW * (DCol - C); if (MaxDistSq >= RowDistSq + ColDist * ColDist) { if (0 != FlagGet(Cells, R, C)) { G_debug(2, "unset()"); FLAG_UNSET(Cells, R, C); CellCount--; } } else { C = 0; } } } } G_debug(2, "it3()"); for (R = DRow - 1; R >= 0; R--) { RowDist = NS * (DRow - R); if (RowDist > MaxDistSq) { R = 0; } else { RowDistSq = RowDist * RowDist; for (C = DCol - 1; C >= 0; C--) { ColDist = EW * (DCol - C); if (MaxDistSq >= RowDistSq + ColDist * ColDist) { if (0 != FlagGet(Cells, R, C)) { G_debug(2, "unset()"); FLAG_UNSET(Cells, R, C); CellCount--; } } else { C = 0; } } } } } } G_debug(2, "outputting()"); OutFD = Rast_open_c_new(Output->answer); G_message(_("Writing raster map <%s>..."), Output->answer); for (R = 0; R < Rs; R++) { G_percent(R, Rs, 2); for (C = 0; C < Cs; C++) { CellBuffer[C] = Out[R][C]; } Rast_put_row(OutFD, CellBuffer, CELL_TYPE); } G_percent(1, 1, 1); Rast_close(OutFD); Rast_short_history(Output->answer, "raster", &history); Rast_command_history(&history); Rast_write_history(Output->answer, &history); }
void Init() { struct Cell_head Region; int Count; int FD, row, col; double MinRes; G_debug(2, "Init()"); Rs = Rast_window_rows(); Cs = Rast_window_cols(); G_get_set_window(&Region); EW = Region.ew_res; NS = Region.ns_res; if (EW < NS) MinRes = EW; else MinRes = NS; CellBuffer = Rast_allocate_c_buf(); /* Out = FlagCreate( Rs, Cs); */ Out = (CELL **) G_malloc(sizeof(CELL *) * Rs); for (row = 0; row < Rs; row++) { Out[row] = Rast_allocate_c_buf(); Rast_zero_buf(Out[row], CELL_TYPE); } Cells = FlagCreate(Rs, Cs); CellCount = 0; if (G_find_raster2("MASK", G_mapset())) { FD = Rast_open_old("MASK", G_mapset()); { for (row = 0; row < Rs; row++) { Rast_get_c_row_nomask(FD, CellBuffer, row); for (col = 0; col < Cs; col++) { if (CellBuffer[col]) { FLAG_SET(Cells, row, col); CellCount++; } } } Rast_close(FD); } } else { for (row = 0; row < Rs; row++) { for (col = 0; col < Cs; col++) { FLAG_SET(Cells, row, col); } } CellCount = Rs * Cs; } sscanf(Distance->answer, "%lf", &MaxDist); if (MaxDist < 0.0) G_fatal_error(_("Distance must be >= 0.0")); G_debug(3, "(MaxDist):%.12lf", MaxDist); MaxDistSq = MaxDist * MaxDist; if (!SeedStuff->answer) { Seed = (int)getpid(); } else { sscanf(SeedStuff->answer, "%d", &(Seed)); } if (Seed > SEED_MAX) { Seed = Seed % SEED_MAX; } else if (Seed < SEED_MIN) { while (Seed < SEED_MIN) Seed += SEED_MAX - SEED_MIN; } G_message(_("Generating raster map <%s>..."), Output->answer); DoNext = (CELLSORTER *) G_malloc(CellCount * sizeof(CELLSORTER)); Count = 0; for (row = 0; row < Rs; row++) { G_percent(row, Rs, 2); for (col = 0; col < Cs; col++) { if (0 != FlagGet(Cells, row, col)) { DoNext[Count].R = row; DoNext[Count].C = col; DoNext[Count].Value = GasDev(); if (++Count == CellCount) { row = Rs; col = Cs; } } } } G_percent(1, 1, 1); qsort(DoNext, CellCount, sizeof(CELLSORTER), comp_array); }
bool8 ScrCmd_checkflag(struct ScriptContext *ctx) { ctx->comparisonResult = FlagGet(ScriptReadHalfword(ctx)); return FALSE; }