int main(void) { DDRA |= _BV(DDA0); // PortA pin 0 as output DDRB = 0x00; while(1){ while(1) { if(PINB & (1<<PB0)){ // you need to give logic 1 to this shit Button1(); } if(PINB & (1<<PB1)){ // you need to give logic 1 to this shit Button2(); } PORTA ^= _BV(PA0); _delay_ms(1000); } } }
void CMyDlg::OnLButtonDown(UINT nFlags, CPoint point) { CPoint Button1(165,122); CPoint Button2(350,122); if (isRect(point,Button1)) { crack(); } if (isRect(point,Button2)) restore(); SendMessage(WM_NCLBUTTONDOWN,(WPARAM)HTCAPTION,(LPARAM)HTCAPTION); CDialog::OnLButtonDown(nFlags, point); }
void Mission_Data_Buttons(char plr, int *where) { char index, yr, season, j, temp = 0; /* Okay, now we have to decide whether there are any missions displayed on the screen at this time. If there are any, parse the button. */ if (Data->P[plr].PastMissionCount == 0) { return; } index = 0; season = *where % 2; yr = (*where - season) / 2 + 57; while (yr > Data->P[plr].History[index].MissionYear) { index++; } if (Data->P[plr].History[index].MissionYear > yr) { return; } if (season == 1) { while (Data->P[plr].History[index].Month < 6) { index++; } if (Data->P[plr].History[index].MissionYear > yr) { return; } } do { if (Data->P[plr].History[index].Month > 6 && season == 0) { break; } j = (Data->P[plr].History[index].Month < 6) ? Data->P[plr].History[index].Month : Data->P[plr].History[index].Month - 6; Button2(13 + 49 * j, 40 * (1 + temp), 62 + 49 * j, 40 * (2 + temp) , Draw_Mis_Stats(plr, index, where, 0), key, 0x31 + temp); temp++; index++; } while (Data->P[plr].History[index].MissionYear == yr); }
void MenuActivate(MenuSystem *ms, menu_t *menu, int cmd) { UNUSED(ms); MenuPlaySound(MENU_SOUND_SWITCH); switch (menu->type) { case MENU_TYPE_BASIC: // do nothing return; case MENU_TYPE_SET_OPTION_TOGGLE: *menu->u.option.uHook.optionToggle = !*menu->u.option.uHook.optionToggle; break; case MENU_TYPE_SET_OPTION_RANGE: { int option = *menu->u.option.uHook.optionRange.option; int increment = menu->u.option.uHook.optionRange.increment; int low = menu->u.option.uHook.optionRange.low; int high = menu->u.option.uHook.optionRange.high; if (Left(cmd)) { if (low == option) { option = high; } else if (low + increment > option) { option = low; } else { option -= increment; } } else if (Right(cmd)) { if (high == option) { option = low; } else if (high - increment < option) { option = high; } else { option += increment; } } *menu->u.option.uHook.optionRange.option = option; } break; case MENU_TYPE_SET_OPTION_SEED: { unsigned int seed = *menu->u.option.uHook.seed; unsigned int increment = 1; if (Button1(cmd)) { increment *= 10; } if (Button2(cmd)) { increment *= 100; } if (Left(cmd)) { if (increment > seed) { seed = 0; } else { seed -= increment; } } else if (Right(cmd)) { if (UINT_MAX - increment < seed) { seed = UINT_MAX; } else { seed += increment; } } *menu->u.option.uHook.seed = seed; } break; case MENU_TYPE_SET_OPTION_UP_DOWN_VOID_FUNC_VOID: if (Left(cmd)) { menu->u.option.uHook.upDownFuncs.upFunc(); } else if (Right(cmd)) { menu->u.option.uHook.upDownFuncs.downFunc(); } break; case MENU_TYPE_SET_OPTION_RANGE_GET_SET: { int option = menu->u.option.uHook.optionRangeGetSet.getFunc(); int increment = menu->u.option.uHook.optionRangeGetSet.increment; if (Left(cmd)) { if (menu->u.option.uHook.optionRangeGetSet.low + increment > option) { option = menu->u.option.uHook.optionRangeGetSet.low; } else { option -= increment; } } else if (Right(cmd)) { if (menu->u.option.uHook.optionRangeGetSet.high - increment < option) { option = menu->u.option.uHook.optionRangeGetSet.high; } else { option += increment; } } menu->u.option.uHook.optionRangeGetSet.setFunc(option); } break; case MENU_TYPE_VOID_FUNC: menu->u.option.uHook.voidFunc.func(menu->u.option.uHook.voidFunc.data); break; case MENU_TYPE_SET_OPTION_CHANGE_KEY: menu->parentMenu->u.normal.changeKeyMenu = menu; break; default: printf("Error unhandled menu type %d\n", menu->type); assert(0); break; } }
void ShowPrest(char plr) { char pos = -1, pos2 = -1; int i, j; for (j = 0; j < 2; j++) for (i = 0; i < 28; i++) { TPoints[j] += (int) Data->Prestige[i].Points[j]; } FadeOut(2, display::graphics.palette(), 5, 0, 0); PortPal(plr); display::graphics.screen()->clear(0); ShBox(0, 0, 319, 22); ShBox(0, 24, 319, 199); InBox(4, 27, 315, 196); fill_rectangle(5, 28, 314, 195, 0); //ShBox(6,29,125,101); ShBox(6, 29, 56, 101); InBox(17, 46, 44, 62); InBox(70, 42, 174, 92); ShBox(179, 29, 313, 101); ShBox(58, 29, 313, 101); InBox(70, 42, 174, 92); InBox(185, 42, 304, 92); //ShBox(136,74,163,90); IOBox(243, 3, 316, 19); ShBox(6, 104, 313, 194); InBox(10, 127, 309, 191); fill_rectangle(11, 128, 308, 190, 0); ShBox(297, 129, 307, 158); ShBox(297, 160, 307, 189); // Arrows draw_heading(8, 5, "PRESTIGE SUMMARY", 0, -1); draw_heading(14, 109, "EVENTS", 0, -1); display::graphics.setForegroundColor(11); draw_string(140, 120, "1ST:"); draw_string(175, 120, "2ND:"); draw_string(212, 120, "SUBS:"); draw_string(254, 120, "FAIL:"); display::graphics.setForegroundColor(1); draw_string(257, 13, "CONTINUE"); draw_string(17, 39, "FIRST:"); draw_string(19, 81, "DATE:"); display::graphics.setForegroundColor(11); draw_string(71, 37, "# SPACE FIRSTS:"); draw_string(187, 37, "TOTAL POINTS:"); display::graphics.setForegroundColor(1); display::graphics.setForegroundColor(6); draw_string(210, 99, "USA"); draw_string(90, 99, "USA"); display::graphics.setForegroundColor(9); draw_string(261, 99, "USSR"); draw_string(135, 99, "USSR"); draw_up_arrow(299, 131); draw_down_arrow(299, 162); DPrest(plr, &pos, &pos2); FadeIn(2, display::graphics.palette(), 5, 0, 0); WaitForMouseUp(); while (1) { GetMouse(); // Parse Button actions, note that return is embedded in first pButton if ((x >= 245 && y >= 5 && x <= 314 && y <= 17 && mousebuttons > 0) || key == K_ENTER) { InBox(245, 5, 314, 17); if (key > 0) { delay(300); key = 0; }; WaitForMouseUp(); OutBox(245, 5, 314, 17); key = 0; helpText = "i000"; keyHelpText = "k000"; return; } pButton(297, 129, 307, 158, BackOne(plr, &pos, &pos2), key >> 8, 72); pButton(297, 160, 307, 189, ForOne(plr, &pos, &pos2), key >> 8, 80); Button2(15, 129, 160, 133, Move2(plr, &pos, &pos2, 0), key, 49); Button2(15, 136, 160, 140, Move2(plr, &pos, &pos2, 1), key, 50); Button2(15, 143, 160, 147, Move2(plr, &pos, &pos2, 2), key, 51); Button2(15, 150, 160, 154, Move2(plr, &pos, &pos2, 3), key, 52); Button2(15, 157, 160, 161, Move2(plr, &pos, &pos2, 4), key, 53); Button2(15, 164, 160, 168, Move2(plr, &pos, &pos2, 5), key, 54); Button2(15, 171, 160, 175, Move2(plr, &pos, &pos2, 6), key, 55); Button2(15, 178, 160, 182, Move2(plr, &pos, &pos2, 7), key, 56); Button2(15, 185, 160, 189, Move2(plr, &pos, &pos2, 8), key, 57); key = 0; }; }
void MenuActivate(menu_t *menu, int cmd) { Config lastConfig = gConfig; SoundPlay(&gSoundDevice, SND_SWITCH); switch (menu->type) { case MENU_TYPE_SET_OPTION_TOGGLE: *menu->u.option.uHook.optionToggle = !*menu->u.option.uHook.optionToggle; break; case MENU_TYPE_SET_OPTION_RANGE: { int option = *menu->u.option.uHook.optionRange.option; int increment = menu->u.option.uHook.optionRange.increment; if (Left(cmd)) { if (menu->u.option.uHook.optionRange.low + increment > option) { option = menu->u.option.uHook.optionRange.low; } else { option -= increment; } } else if (Right(cmd)) { if (menu->u.option.uHook.optionRange.high - increment < option) { option = menu->u.option.uHook.optionRange.high; } else { option += increment; } } *menu->u.option.uHook.optionRange.option = option; } break; case MENU_TYPE_SET_OPTION_SEED: { unsigned int seed = *menu->u.option.uHook.seed; unsigned int increment = 1; if (Button1(cmd)) { increment *= 10; } if (Button2(cmd)) { increment *= 100; } if (Left(cmd)) { if (increment > seed) { seed = 0; } else { seed -= increment; } } else if (Right(cmd)) { if (UINT_MAX - increment < seed) { seed = UINT_MAX; } else { seed += increment; } } *menu->u.option.uHook.seed = seed; } break; case MENU_TYPE_SET_OPTION_UP_DOWN_VOID_FUNC_VOID: if (Left(cmd)) { menu->u.option.uHook.upDownFuncs.upFunc(); } else if (Right(cmd)) { menu->u.option.uHook.upDownFuncs.downFunc(); } break; case MENU_TYPE_SET_OPTION_RANGE_GET_SET: { int option = menu->u.option.uHook.optionRangeGetSet.getFunc(); int increment = menu->u.option.uHook.optionRangeGetSet.increment; if (Left(cmd)) { if (menu->u.option.uHook.optionRangeGetSet.low + increment > option) { option = menu->u.option.uHook.optionRangeGetSet.low; } else { option -= increment; } } else if (Right(cmd)) { if (menu->u.option.uHook.optionRangeGetSet.high - increment < option) { option = menu->u.option.uHook.optionRangeGetSet.high; } else { option += increment; } } menu->u.option.uHook.optionRangeGetSet.setFunc(option); } break; case MENU_TYPE_SET_OPTION_CHANGE_CONTROL: InputChangeDevice( menu->u.option.uHook.changeControl.device0, menu->u.option.uHook.changeControl.device1, gJoysticks.numJoys); break; case MENU_TYPE_VOID_FUNC_VOID: menu->u.option.uHook.toggleFuncs.toggle(); break; case MENU_TYPE_SET_OPTION_CHANGE_KEY: menu->parentMenu->u.normal.changeKeyMenu = menu; break; default: printf("Error unhandled menu type %d\n", menu->type); assert(0); break; } if (!ConfigApply(&gConfig)) { printf("Error: cannot apply new config; applying last config\n"); gConfig = lastConfig; if (!ConfigApply(&gConfig)) { printf("Error: cannot apply last config!\n"); exit(1); } } }
void MenuActivate(MenuSystem *ms, menu_t *menu, int cmd) { Config lastConfig = gConfig; MenuPlaySound(MENU_SOUND_SWITCH); switch (menu->type) { case MENU_TYPE_BASIC: // do nothing // TODO: change ConfigApply to a custom hook return; case MENU_TYPE_SET_OPTION_TOGGLE: *menu->u.option.uHook.optionToggle = !*menu->u.option.uHook.optionToggle; break; case MENU_TYPE_SET_OPTION_RANGE: { int option = *menu->u.option.uHook.optionRange.option; int increment = menu->u.option.uHook.optionRange.increment; int low = menu->u.option.uHook.optionRange.low; int high = menu->u.option.uHook.optionRange.high; if (Left(cmd)) { if (low == option) { option = high; } else if (low + increment > option) { option = low; } else { option -= increment; } } else if (Right(cmd)) { if (high == option) { option = low; } else if (high - increment < option) { option = high; } else { option += increment; } } *menu->u.option.uHook.optionRange.option = option; } break; case MENU_TYPE_SET_OPTION_SEED: { unsigned int seed = *menu->u.option.uHook.seed; unsigned int increment = 1; if (Button1(cmd)) { increment *= 10; } if (Button2(cmd)) { increment *= 100; } if (Left(cmd)) { if (increment > seed) { seed = 0; } else { seed -= increment; } } else if (Right(cmd)) { if (UINT_MAX - increment < seed) { seed = UINT_MAX; } else { seed += increment; } } *menu->u.option.uHook.seed = seed; } break; case MENU_TYPE_SET_OPTION_UP_DOWN_VOID_FUNC_VOID: if (Left(cmd)) { menu->u.option.uHook.upDownFuncs.upFunc(); } else if (Right(cmd)) { menu->u.option.uHook.upDownFuncs.downFunc(); } break; case MENU_TYPE_SET_OPTION_RANGE_GET_SET: { int option = menu->u.option.uHook.optionRangeGetSet.getFunc(); int increment = menu->u.option.uHook.optionRangeGetSet.increment; if (Left(cmd)) { if (menu->u.option.uHook.optionRangeGetSet.low + increment > option) { option = menu->u.option.uHook.optionRangeGetSet.low; } else { option -= increment; } } else if (Right(cmd)) { if (menu->u.option.uHook.optionRangeGetSet.high - increment < option) { option = menu->u.option.uHook.optionRangeGetSet.high; } else { option += increment; } } menu->u.option.uHook.optionRangeGetSet.setFunc(option); } break; case MENU_TYPE_VOID_FUNC_VOID: menu->u.option.uHook.toggleFuncs.toggle(); break; case MENU_TYPE_SET_OPTION_CHANGE_KEY: menu->parentMenu->u.normal.changeKeyMenu = menu; break; default: printf("Error unhandled menu type %d\n", menu->type); assert(0); break; } if (!ConfigApply(&gConfig)) { printf("Error: cannot apply new config; applying last config\n"); gConfig = lastConfig; if (!ConfigApply(&gConfig)) { printf("Error: cannot apply last config!\n"); exit(1); } } // Update menu system // Note: only for the main menu system! ms->pos = Vec2iZero(); ms->size = Vec2iNew( ms->graphics->cachedConfig.ResolutionWidth, ms->graphics->cachedConfig.ResolutionHeight); }
int SelectOptions(int cmd) { static int index = 0; char s[10]; int x, y; if (cmd == CMD_ESC) return MODE_MAIN; if (AnyButton(cmd) || Left(cmd) || Right(cmd)) { switch (index) { case 0: gOptions.playersHurt = !gOptions.playersHurt; PlaySound(SND_KILL, 0, 255); break; case 1: gOptions.displayFPS = !gOptions.displayFPS; PlaySound(SND_FLAMER, 0, 255); break; case 2: gOptions.displayTime = !gOptions.displayTime; PlaySound(SND_LAUNCH, 0, 255); break; case 3: if (gOptions.copyMode == COPY_REPMOVSD) gOptions.copyMode = COPY_DEC_JNZ; else gOptions.copyMode = COPY_REPMOVSD; PlaySound(SND_EXPLOSION, 0, 255); break; case 4: if (Left(cmd) && gOptions.brightness > -10) gOptions.brightness--; else if (Right(cmd) && gOptions.brightness < 10) gOptions.brightness++; else break; PlaySound(SND_POWERGUN, 0, 255); PaletteAdjust(); break; case 5: if (gOptions.xSplit == 0) { gOptions.xSplit = SPLIT_X; gOptions.ySplit = SPLIT_Y; } else { gOptions.xSplit = gOptions.ySplit = 0; } PlaySound(SND_KILL3, 0, 255); break; case 6: if (Left(cmd)) { if (Button1(cmd) && Button2(cmd)) gCampaign.seed -= 1000; else if (Button1(cmd)) gCampaign.seed -= 10; else if (Button2(cmd)) gCampaign.seed -= 100; else gCampaign.seed--; } else if (Right(cmd)) { if (Button1(cmd) && Button2(cmd)) gCampaign.seed += 1000; else if (Button1(cmd)) gCampaign.seed += 10; else if (Button2(cmd)) gCampaign.seed += 100; else gCampaign.seed++; } break; case 7: if (Left(cmd)) { if (gOptions.difficulty > DIFFICULTY_VERYEASY) gOptions.difficulty--; } else if (Right(cmd)) { if (gOptions.difficulty < DIFFICULTY_VERYHARD) gOptions.difficulty++; } if (gOptions.difficulty > DIFFICULTY_VERYHARD) gOptions.difficulty = DIFFICULTY_VERYHARD; if (gOptions.difficulty < DIFFICULTY_VERYEASY) gOptions.difficulty = DIFFICULTY_VERYEASY; break; case 8: gOptions.slowmotion = !gOptions.slowmotion; break; case 9: if (Left(cmd)) { if (gOptions.density > 25) gOptions.density -= 25; } else if (Right(cmd)) { if (gOptions.density < 200) gOptions.density += 25; } break; case 10: if (Left(cmd)) { if (gOptions.npcHp > 25) gOptions.npcHp -= 25; } else if (Right(cmd)) { if (gOptions.npcHp < 200) gOptions.npcHp += 25; } break; case 11: if (Left(cmd)) { if (gOptions.playerHp > 25) gOptions.playerHp -= 25; } else if (Right(cmd)) { if (gOptions.playerHp < 200) gOptions.playerHp += 25; } break; case 12: Gfx_HintToggle(HINT_FULLSCREEN); InitVideo(); break; case 13: { GFX_Mode *m = NULL; if (Left(cmd)) { m = Gfx_ModePrev(); } else if (Right(cmd)) { m = Gfx_ModeNext(); } if (m) { debug(D_NORMAL, "new mode? %d x %d\n", m->w, m->h); Gfx_SetHint(HINT_WIDTH, m->w); Gfx_SetHint(HINT_HEIGHT, m->h); } } break; case 14: { int fac = Gfx_GetHint(HINT_SCALEFACTOR); if (Left(cmd)) { fac--; } else if (Right(cmd)) { fac++; } if (fac >= 1 && fac <= 4) { Gfx_SetHint(HINT_SCALEFACTOR, (const int)fac); InitVideo(); } } break; default: PlaySound(SND_BANG, 0, 255); return MODE_MAIN; } } if (Up(cmd)) { index--; if (index < 0) index = OPTIONS_COUNT - 1; PlaySound(SND_SWITCH, 0, 255); } else if (Down(cmd)) { index++; if (index >= OPTIONS_COUNT) index = 0; PlaySound(SND_SWITCH, 0, 255); } TextStringSpecial("Game Options:", TEXT_XCENTER | TEXT_TOP, 0, (SCREEN_WIDTH / 12)); x = CenterX(MenuWidth(optionsMenu, OPTIONS_COUNT)); y = CenterY(MenuHeight(optionsMenu, OPTIONS_COUNT)); DisplayMenuAt(x - 20, y, optionsMenu, OPTIONS_COUNT, index); x += MenuWidth(optionsMenu, OPTIONS_COUNT); x += 10; TextStringAt(x, y, gOptions.playersHurt ? "Yes" : "No"); TextStringAt(x, y + TextHeight(), gOptions.displayFPS ? "On" : "Off"); TextStringAt(x, y + 2 * TextHeight(), gOptions.displayTime ? "On" : "Off"); TextStringAt(x, y + 3 * TextHeight(), gOptions.copyMode == COPY_REPMOVSD ? "rep movsd" : "dec/jnz"); sprintf(s, "%d", gOptions.brightness); TextStringAt(x, y + 4 * TextHeight(), s); TextStringAt(x, y + 5 * TextHeight(), gOptions.xSplit ? "No" : "Yes"); sprintf(s, "%u", gCampaign.seed); TextStringAt(x, y + 6 * TextHeight(), s); switch (gOptions.difficulty) { case DIFFICULTY_VERYEASY: strcpy(s, "Easiest"); break; case DIFFICULTY_EASY: strcpy(s, "Easy"); break; case DIFFICULTY_HARD: strcpy(s, "Hard"); break; case DIFFICULTY_VERYHARD: strcpy(s, "Very hard"); break; default: strcpy(s, "Normal"); break; } TextStringAt(x, y + 7 * TextHeight(), s); TextStringAt(x, y + 8 * TextHeight(), gOptions.slowmotion ? "Yes" : "No"); sprintf(s, "%u%%", gOptions.density); TextStringAt(x, y + 9 * TextHeight(), s); sprintf(s, "%u%%", gOptions.npcHp); TextStringAt(x, y + 10 * TextHeight(), s); sprintf(s, "%u%%", gOptions.playerHp); TextStringAt(x, y + 11 * TextHeight(), s); sprintf(s, "%s", Gfx_GetHint(HINT_FULLSCREEN) ? "Yes" : "No"); TextStringAt(x, y + 12 * TextHeight(), s); sprintf(s, "%dx%d", Gfx_GetHint(HINT_WIDTH), Gfx_GetHint(HINT_HEIGHT)); TextStringAt(x, y + 13 * TextHeight(), s); sprintf(s, "%dx", Gfx_GetHint(HINT_SCALEFACTOR)); TextStringAt(x, y + 14 * TextHeight(), s); return MODE_OPTIONS; }