static void HighlightKey(int index) { CopyToScreen(); ShowAllKeys(index, index); return; }
void MenuLoop(MenuSystem *menu) { assert(menu->numExitTypes > 0); for (;; SDL_Delay(10)) { // Input InputPoll(menu->joysticks, menu->keyboard); // Update if (menu->current->type == MENU_TYPE_KEYS && menu->current->u.normal.changeKeyMenu != NULL) { MenuProcessChangeKey(menu->current); } else { int cmd = GetMenuCmd(); menu->current = MenuProcessCmd(menu->current, cmd); } if (MenuHasExitType(menu, menu->current->type)) { break; } // Draw if (menu->bkg != NULL) { memcpy( GetDstScreen(), menu->bkg, GraphicsGetMemSize(&gGraphicsDevice.cachedConfig)); } ShowControls(); MenuDisplay(menu); CopyToScreen(); } }
int MainMenu(void *bkg) { int cmd, prev = 0; int mode; PaletteAdjust(); mode = MODE_MAIN; while (mode != MODE_QUIT && mode != MODE_PLAY) { memcpy(GetDstScreen(), bkg, SCREEN_MEMSIZE); ShowControls(); if (mode == MODE_MAIN) ShowCredits(); GetMenuCmd(&cmd); if (cmd == prev) cmd = 0; else prev = cmd; mode = MakeSelection(mode, cmd); CopyToScreen(); SDL_Delay(10); } WaitForRelease(); return mode == MODE_PLAY; }
static void Save(int asCode) { char filename[128]; // char drive[_MAX_DRIVE]; char dir[96]; char name[32]; // char ext[_MAX_EXT]; char c; int i; strcpy(filename, lastFile); while (1) { memset(GetDstScreen(), 58, 64000); TextStringAt(125, 50, "Save as:"); TextGoto(125, 50 + TextHeight()); TextChar('\020'); TextString(filename); TextChar('\021'); vsync(); CopyToScreen(); c = GetKey(); switch (c) { case ENTER: if (!filename[0]) break; if (asCode) { SaveCampaignAsC(filename, name, &campaign); } else { SaveCampaign(filename, &campaign); } fileChanged = 0; return; case ESCAPE: return; case BACKSPACE: if (filename[0]) filename[strlen(filename) - 1] = 0; break; default: if (strlen(filename) == sizeof(filename) - 1) break; c = toupper(c); if ((c >= 'A' && c <= 'Z') || c == '-' || c == '_' || c == '\\') { i = strlen(filename); filename[i + 1] = 0; filename[i] = c; } } } }
int PlayerEquip(void *bkg) { int cmd1, cmd2, prev1 = 0, prev2 = 0; int done1 = 0, done2; debug(D_NORMAL, "\n"); done2 = gOptions.twoPlayers ? 0 : 1; while (!done1 || !done2) { memcpy(GetDstScreen(), bkg, SCREEN_MEMSIZE); GetPlayerCmd(&cmd1, &cmd2); if (KeyDown(keyEsc)) return 0; // hack to exit from menu if (gOptions.twoPlayers) { if (cmd1 == prev1) cmd1 = 0; else prev1 = cmd1; // if (!done1) // || !gPlayer1Data.weaponCount < MAX_WEAPONS) done1 = !WeaponSelection(CenterOfLeft(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1, done1); ShowSelection(CenterOfLeft(50), &gPlayer1Data,CHARACTER_PLAYER1); ShowPlayerControls(CenterOfLeft(100), &gPlayer1Data); if (cmd2 == prev2) cmd2 = 0; else prev2 = cmd2; // if (!done2) // || gPlayer2Data.weaponCount < MAX_WEAPONS) done2 = !WeaponSelection(CenterOfRight(50), CHARACTER_PLAYER2, &gPlayer2Data, cmd2, done2); ShowSelection(CenterOfRight(50), &gPlayer2Data, CHARACTER_PLAYER2); ShowPlayerControls(CenterOfRight(100), &gPlayer2Data); } else { if (cmd1 == prev1) cmd1 = 0; else prev1 = cmd1; if (!done1) // || gPlayer1Data.weaponCount <= 0) done1 = !WeaponSelection(CenterX(80), CHARACTER_PLAYER1, &gPlayer1Data, cmd1, done1); ShowSelection(CenterX(80), &gPlayer1Data, CHARACTER_PLAYER1); ShowPlayerControls(CenterX(100), &gPlayer1Data); } CopyToScreen(); } WaitForRelease(); return 1; }
void Chart::DrawToScreen(sf::RenderWindow* window) { LogFnStart(); CreateTexture(); LoadFonts(); Render(); DrawTextElements(); CopyToScreen(window); LogFnEnd(); }
static int ConfirmQuit(void) { int c; memset(GetDstScreen(), 58, 64000); TextStringAt(80, 50, "Campaign has been modified, but not saved"); TextStringAt(110, 50 + TH, "Quit anyway? (Y/N)"); vsync(); CopyToScreen(); c = GetKey(); return (c == 'Y' || c == 'y'); }
int PlayerSelection(int twoPlayers, void *bkg) { int cmd1, cmd2, prev1 = 0, prev2 = 0; int mode1, mode2; mode1 = MODE_MAIN; mode2 = twoPlayers ? MODE_MAIN : MODE_DONE; SetPlayer(0, &gPlayer1Data); SetPlayer(1, &gPlayer2Data); while (mode1 != MODE_DONE || mode2 != MODE_DONE) { memcpy(GetDstScreen(), bkg, SCREEN_MEMSIZE); GetPlayerCmd(&cmd1, &cmd2); if (KeyDown(keyEsc)) return 0; // hack to allow exit if (twoPlayers) { if (cmd1 == prev1) cmd1 = 0; else prev1 = cmd1; mode1 = MakeSelection(mode1, CenterOfLeft(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1); if (cmd2 == prev2) cmd2 = 0; else prev2 = cmd2; mode2 = MakeSelection(mode2, CenterOfRight(50), CHARACTER_PLAYER2, &gPlayer2Data, cmd2); } else { if (cmd1 == prev1) cmd1 = 0; else prev1 = cmd1; mode1 = MakeSelection(mode1, CenterX(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1); } CopyToScreen(); } WaitForRelease(); return 1; }
static int DisplayPage(const char *title, int index, struct Entry *e, int hilite1, int hilite2) { int x = 80; int y = 5; CDogsTextStringAt(5, 5, title); while (index < MAX_ENTRY && e[index].score > 0 && x < 300) { y += DisplayEntry(x, y, index, &e[index], index == hilite1 || index == hilite2); if (y > 198 - CDogsTextHeight()) { y = 20; x += 100; } index++; } CopyToScreen(); return index; }
void CLiveCameraDlg::OnPaint() { CPaintDC dc(this); // device context for painting if (( pImage != NULL) && (sizeX != 0) && (sizeY != 0) ) { GetClientRect (&m_rect); double zoomX; double zoomY; zoomX= double(m_rect.Width() - 2 * _BORDER) / double(sizeX); zoomY = double(m_rect.Height() - 2 * _BORDER) / double(sizeY); unsigned char *dib = (unsigned char*)m_converter.ConvertAndFlipToDIB(*pImage); CopyToScreen(m_drawdib, dc.GetSafeHdc(), dib, _BORDER, _BORDER, zoomX, zoomY); } // Do not call CDialog::OnPaint() for painting messages }
int PlayerEquip(void *bkg) { int done1 = 0, done2; debug(D_NORMAL, "\n"); done2 = gOptions.twoPlayers ? 0 : 1; while (!done1 || !done2) { int cmd1 = 0; int cmd2 = 0; InputPoll(&gJoysticks, &gKeyboard); memcpy(GetDstScreen(), bkg, GraphicsGetMemSize(&gGraphicsDevice.cachedConfig)); GetPlayerCmd(&cmd1, &cmd2, 1); if (KeyIsPressed(&gKeyboard, keyEsc)) return 0; // hack to exit from menu if (gOptions.twoPlayers) { done1 = !WeaponSelection(CenterOfLeft(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1, done1); ShowSelection(CenterOfLeft(50), &gPlayer1Data,CHARACTER_PLAYER1); ShowPlayerControls(CenterOfLeft(100), &gConfig.Input.PlayerKeys[0]); done2 = !WeaponSelection(CenterOfRight(50), CHARACTER_PLAYER2, &gPlayer2Data, cmd2, done2); ShowSelection(CenterOfRight(50), &gPlayer2Data, CHARACTER_PLAYER2); ShowPlayerControls(CenterOfRight(100), &gConfig.Input.PlayerKeys[1]); } else { done1 = !WeaponSelection(CenterX(80), CHARACTER_PLAYER1, &gPlayer1Data, cmd1, done1); ShowSelection(CenterX(80), &gPlayer1Data, CHARACTER_PLAYER1); ShowPlayerControls(CenterX(100), &gConfig.Input.PlayerKeys[0]); } CopyToScreen(); SDL_Delay(10); } return 1; }
int PlayerSelection(int twoPlayers, void *bkg) { int mode1, mode2; mode1 = MODE_MAIN; mode2 = twoPlayers ? MODE_MAIN : MODE_DONE; SetPlayer(0, &gPlayer1Data); SetPlayer(1, &gPlayer2Data); KeyInit(&gKeyboard); while (mode1 != MODE_DONE || mode2 != MODE_DONE) { int cmd1 = 0; int cmd2 = 0; InputPoll(&gJoysticks, &gKeyboard); memcpy(GetDstScreen(), bkg, GraphicsGetMemSize(&gGraphicsDevice.cachedConfig)); GetPlayerCmd(&cmd1, &cmd2, 1); if (KeyIsPressed(&gKeyboard, keyEsc)) return 0; // hack to allow exit if (twoPlayers) { mode1 = MakeSelection(mode1, CenterOfLeft(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1); mode2 = MakeSelection(mode2, CenterOfRight(50), CHARACTER_PLAYER2, &gPlayer2Data, cmd2); } else { mode1 = MakeSelection(mode1, CenterX(50), CHARACTER_PLAYER1, &gPlayer1Data, cmd1); } CopyToScreen(); SDL_Delay(10); } return 1; }
static void Display(TCampaignSetting * setting, int index, int xc, int yc) { int x, y = 10; char s[50]; const TBadGuy *b; int i; memset(GetDstScreen(), 74, SCREEN_MEMSIZE); sprintf(s, "%d/%d", setting->characterCount, MAX_CHARACTERS); TextStringAt(10, 190, s); if (index >= 0 && index < setting->characterCount) { b = &setting->characters[index]; DisplayText(30, y, "Face", yc == YC_APPEARANCE && xc == XC_FACE); DisplayText(60, y, "Skin", yc == YC_APPEARANCE && xc == XC_SKIN); DisplayText(90, y, "Hair", yc == YC_APPEARANCE && xc == XC_HAIR); DisplayText(120, y, "Body", yc == YC_APPEARANCE && xc == XC_BODY); DisplayText(150, y, "Arms", yc == YC_APPEARANCE && xc == XC_ARMS); DisplayText(180, y, "Legs", yc == YC_APPEARANCE && xc == XC_LEGS); y += TextHeight(); sprintf(s, "Speed: %d%%", (100 * b->speed) / 256); DisplayText(20, y, s, yc == YC_ATTRIBUTES && xc == XC_SPEED); sprintf(s, "Hp: %d", b->health); DisplayText(70, y, s, yc == YC_ATTRIBUTES && xc == XC_HEALTH); sprintf(s, "Move: %d%%", b->probabilityToMove); DisplayText(120, y, s, yc == YC_ATTRIBUTES && xc == XC_MOVE); sprintf(s, "Track: %d%%", b->probabilityToTrack); DisplayText(170, y, s, yc == YC_ATTRIBUTES && xc == XC_TRACK); sprintf(s, "Shoot: %d%%", b->probabilityToShoot); DisplayText(220, y, s, yc == YC_ATTRIBUTES && xc == XC_SHOOT); sprintf(s, "Delay: %d", b->actionDelay); DisplayText(270, y, s, yc == YC_ATTRIBUTES && xc == XC_DELAY); y += TextHeight(); DisplayFlag(5, y, "Asbestos", (b->flags & FLAGS_ASBESTOS) != 0, yc == YC_FLAGS && xc == XC_ASBESTOS); DisplayFlag(50, y, "Immunity", (b->flags & FLAGS_IMMUNITY) != 0, yc == YC_FLAGS && xc == XC_IMMUNITY); DisplayFlag(95, y, "C-thru", (b->flags & FLAGS_SEETHROUGH) != 0, yc == YC_FLAGS && xc == XC_SEETHROUGH); DisplayFlag(140, y, "Run-away", (b->flags & FLAGS_RUNS_AWAY) != 0, yc == YC_FLAGS && xc == XC_RUNS_AWAY); DisplayFlag(185, y, "Sneaky", (b->flags & FLAGS_SNEAKY) != 0, yc == YC_FLAGS && xc == XC_SNEAKY); DisplayFlag(230, y, "Good guy", (b->flags & FLAGS_GOOD_GUY) != 0, yc == YC_FLAGS && xc == XC_GOOD_GUY); DisplayFlag(275, y, "Asleep", (b->flags & FLAGS_SLEEPALWAYS) != 0, yc == YC_FLAGS && xc == XC_SLEEPING); y += TextHeight(); DisplayFlag(5, y, "Prisoner", (b->flags & FLAGS_PRISONER) != 0, yc == YC_FLAGS2 && xc == XC_PRISONER); DisplayFlag(50, y, "Invuln.", (b->flags & FLAGS_INVULNERABLE) != 0, yc == YC_FLAGS2 && xc == XC_INVULNERABLE); DisplayFlag(95, y, "Follower", (b->flags & FLAGS_FOLLOWER) != 0, yc == YC_FLAGS2 && xc == XC_FOLLOWER); DisplayFlag(140, y, "Penalty", (b->flags & FLAGS_PENALTY) != 0, yc == YC_FLAGS2 && xc == XC_PENALTY); DisplayFlag(185, y, "Victim", (b->flags & FLAGS_VICTIM) != 0, yc == YC_FLAGS2 && xc == XC_VICTIM); DisplayFlag(230, y, "Awake", (b->flags & FLAGS_AWAKEALWAYS) != 0, yc == YC_FLAGS2 && xc == XC_AWAKE); y += TextHeight(); DisplayText(50, y, gunDesc[b->gun].gunName, yc == YC_WEAPON); y += TextHeight() + 5; x = 10; for (i = 0; i < setting->characterCount; i++) { DisplayCharacter(x, y + 20, &setting->characters[i], index == i); x += 20; if (x > SCREEN_WIDTH) { x = 10; y += 30; } } } CopyToScreen(); }
void Display(int index, int xc, int yc, int key) { char s[128]; int y = 5; int i; SetSecondaryMouseRects(NULL); memset(GetDstScreen(), 58, 64000); sprintf(s, "Key: 0x%x", key); TextStringAt(270, 190, s); DisplayText(25, y, campaign.title, yc == YC_CAMPAIGNTITLE && xc == XC_CAMPAIGNTITLE, 1); if (fileChanged) DrawTPic(10, y, gPics[221], NULL); if (currentMission) { sprintf(s, "Mission %d/%d", index + 1, campaign.missionCount); DisplayText(270, y, s, yc == YC_MISSIONINDEX, 0); y += TextHeight() + 3; DisplayText(25, y, currentMission->title, yc == YC_MISSIONTITLE && xc == XC_MISSIONTITLE, 1); y += TextHeight() + 2; sprintf(s, "Width: %d", currentMission->mapWidth); DisplayText(20, y, s, yc == YC_MISSIONPROPS && xc == XC_WIDTH, 0); sprintf(s, "Height: %d", currentMission->mapHeight); DisplayText(60, y, s, yc == YC_MISSIONPROPS && xc == XC_HEIGHT, 0); sprintf(s, "Walls: %d", currentMission->wallCount); DisplayText(100, y, s, yc == YC_MISSIONPROPS && xc == XC_WALLCOUNT, 0); sprintf(s, "Len: %d", currentMission->wallLength); DisplayText(140, y, s, yc == YC_MISSIONPROPS && xc == XC_WALLLENGTH, 0); sprintf(s, "Rooms: %d", currentMission->roomCount); DisplayText(180, y, s, yc == YC_MISSIONPROPS && xc == XC_ROOMCOUNT, 0); sprintf(s, "Sqr: %d", currentMission->squareCount); DisplayText(220, y, s, yc == YC_MISSIONPROPS && xc == XC_SQRCOUNT, 0); sprintf(s, "Dens: %d", currentMission->baddieDensity); DisplayText(260, y, s, yc == YC_MISSIONPROPS && xc == XC_DENSITY, 0); y += TextHeight(); DisplayText(20, y, "Wall", yc == YC_MISSIONLOOKS && xc == XC_WALL, 0); DisplayText(50, y, "Floor", yc == YC_MISSIONLOOKS && xc == XC_FLOOR, 0); DisplayText(80, y, "Rooms", yc == YC_MISSIONLOOKS && xc == XC_ROOM, 0); DisplayText(110, y, "Doors", yc == YC_MISSIONLOOKS && xc == XC_DOORS, 0); DisplayText(140, y, "Keys", yc == YC_MISSIONLOOKS && xc == XC_KEYS, 0); DisplayText(170, y, "Exit", yc == YC_MISSIONLOOKS && xc == XC_EXIT, 0); sprintf(s, "Walls: %s", RangeName(currentMission->wallRange)); DisplayText(200, y, s, yc == YC_MISSIONLOOKS && xc == XC_COLOR1, 0); sprintf(s, "Floor: %s", RangeName(currentMission->floorRange)); DisplayText(200, y + TH, s, yc == YC_MISSIONLOOKS && xc == XC_COLOR2, 0); sprintf(s, "Rooms: %s", RangeName(currentMission->roomRange)); DisplayText(200, y + 2 * TH, s, yc == YC_MISSIONLOOKS && xc == XC_COLOR3, 0); sprintf(s, "Extra: %s", RangeName(currentMission->altRange)); DisplayText(200, y + 3 * TH, s, yc == YC_MISSIONLOOKS && xc == XC_COLOR4, 0); DrawPic(20, y + TH, gPics[cWallPics [currentMission->wallStyle % WALL_COUNT][WALL_SINGLE]], NULL); DrawPic(50, y + TH, gPics[cFloorPics [currentMission->floorStyle % FLOOR_COUNT][FLOOR_NORMAL]], NULL); DrawPic(80, y + TH, gPics[cRoomPics [currentMission->roomStyle % ROOMFLOOR_COUNT][ROOMFLOOR_NORMAL]], NULL); DrawPic(110, y + TH, gPics[cGeneralPics[gMission.doorPics[0].horzPic]. picIndex], NULL); DrawTPic(140, y + TH, gPics[cGeneralPics[gMission.keyPics[0]].picIndex], NULL); DrawPic(170, y + TH, gPics[gMission.exitPic], NULL); y += TH + 25; DisplayText(20, y, "Mission description", yc == YC_MISSIONDESC, 0); y += TextHeight(); sprintf(s, "Characters (%d/%d)", currentMission->baddieCount, BADDIE_MAX); DisplayText(20, y, s, yc == YC_CHARACTERS, 0); y += TextHeight(); sprintf(s, "Mission objective characters (%d/%d)", currentMission->specialCount, SPECIAL_MAX); DisplayText(20, y, s, yc == YC_SPECIALS, 0); y += TextHeight(); sprintf(s, "Available weapons (%d/%d)", gMission.weaponCount, WEAPON_MAX); DisplayText(20, y, s, yc == YC_WEAPONS, 0); y += TextHeight(); sprintf(s, "Map items (%d/%d)", gMission.objectCount, ITEMS_MAX); DisplayText(20, y, s, yc == YC_ITEMS, 0); y += TextHeight() + 2; if (currentMission->objectiveCount) { for (i = 0; i < currentMission->objectiveCount; i++) { DisplayText(20, y, currentMission->objectives[i]. description, yc - YC_OBJECTIVES == i, 1); y += TextHeight(); } } else DisplayText(20, y, "-- mission objectives --", yc == YC_OBJECTIVES, 0); } else if (campaign.missionCount) { sprintf(s, "End/%d", campaign.missionCount); DisplayText(270, y, s, yc == YC_MISSIONINDEX, 0); } y = 170; switch (yc) { case YC_CAMPAIGNTITLE: DisplayText(20, 150, campaign.author, yc == YC_CAMPAIGNTITLE && xc == XC_AUTHOR, 1); MissionDescription(150 + TH, campaign.description, yc == YC_CAMPAIGNTITLE && xc == XC_CAMPAIGNDESC); SetSecondaryMouseRects(localCampaignClicks); break; case YC_MISSIONTITLE: DisplayText(20, 150, currentMission->song, yc == YC_MISSIONTITLE && xc == XC_MUSICFILE, 1); SetSecondaryMouseRects(localMissionClicks); break; case YC_MISSIONDESC: MissionDescription(150, currentMission->description, yc == YC_MISSIONDESC); break; case YC_CHARACTERS: TextStringAt(5, 190, "Use Insert, Delete and PageUp/PageDown"); if (!currentMission) break; for (i = 0; i < currentMission->baddieCount; i++) DisplayCharacter(20 + 20 * i, y, CHARACTER_OTHERS + i, xc == i); SetSecondaryMouseRects(localCharacterClicks); break; case YC_SPECIALS: TextStringAt(5, 190, "Use Insert, Delete and PageUp/PageDown"); if (!currentMission) break; for (i = 0; i < currentMission->specialCount; i++) DisplayCharacter(20 + 20 * i, y, CHARACTER_OTHERS + currentMission->baddieCount + i, xc == i); SetSecondaryMouseRects(localCharacterClicks); break; case YC_ITEMS: TextStringAt(5, 190, "Use Insert, Delete and PageUp/PageDown"); if (!currentMission) break; for (i = 0; i < currentMission->itemCount; i++) DisplayMapItem(10 + 20 * i, y, gMission.mapObjects[i], currentMission->itemDensity[i], xc == i); break; case YC_WEAPONS: if (!currentMission) break; ListWeapons(150, xc); break; default: if (currentMission && yc >= YC_OBJECTIVES && yc - YC_OBJECTIVES < currentMission->objectiveCount) { TextStringAt(5, 190, "Use Insert, Delete and PageUp/PageDown"); DrawObjectiveInfo(yc - YC_OBJECTIVES, y, xc); } break; } vsync(); CopyToScreen(); }
int gameloop(void) { struct Buffer *buffer; int ticks; int c = 0; int cmd1, cmd2; int done = NO; time_t t; struct tm *tp; buffer = NewBuffer(); SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); if (ModuleStatus() != MODULE_OK) DisplayMessage(ModuleMessage()); gameIsPaused = NO; missionTime = 0; //screenShaking = 0; while (!done) { frames++; Ticks_FrameBegin(); ticks = Ticks_Synchronize(); if (gOptions.displaySlices) SetColorZero(32, 0, 0); DrawScreen(buffer, gPlayer1, gPlayer2); if (gOptions.displaySlices) SetColorZero(0, 0, 0); if (screenShaking) { screenShaking -= ticks; if (screenShaking < 0) screenShaking = 0; } debug(D_VERBOSE, "frames... %d\n", frames); if (Ticks_TimeElapsed(TICKS_PER_SEC)) { fps = frames; debug(D_NORMAL, "fps = %d\n", fps); frames = 0; t = time(NULL); tp = localtime(&t); timeHours = tp->tm_hour; timeMinutes = tp->tm_min; } if (messageTicks > 0) messageTicks -= ticks; StatusDisplay(); if (!gameIsPaused) { missionTime += ticks; if ((gPlayer1 || gPlayer2) && MissionCompleted()) { if (gMission.pickupTime == PICKUP_LIMIT) PlaySound(SND_DONE, 0, 255); gMission.pickupTime -= ticks; if (gMission.pickupTime <= 0) done = YES; } else gMission.pickupTime = PICKUP_LIMIT; } if (gOptions.displaySlices) SetColorZero(0, 0, 32); if (gOptions.displaySlices) SetColorZero(0, 0, 0); CopyToScreen(); if (!gameIsPaused) { if (!gOptions.slowmotion || (frames & 1) == 0) { UpdateAllActors(ticks); UpdateMobileObjects(); GetPlayerInput(&cmd1, &cmd2); if (gPlayer1 && !PlayerSpecialCommands( gPlayer1, cmd1, &gPlayer1Data)) { CommandActor(gPlayer1, cmd1); } if (gPlayer2 && !PlayerSpecialCommands( gPlayer2, cmd2, &gPlayer2Data)) { CommandActor(gPlayer2, cmd2); } if (gOptions.badGuys) CommandBadGuys(); UpdateWatches(); } } else { GetPlayerInput(&cmd1, &cmd2); } if (!gPlayer1 && !gPlayer2) { done = YES; c = 0; } else { c = HandleKey(&done, cmd1 | cmd2); } Ticks_FrameEnd(); } free(buffer); return c != keyEsc; }
void DisplayAutoMap(int showAll) { int x, y, i, j; TTile *tile; unsigned char *p; unsigned char *screen; TTileItem *t; int cmd1, cmd2; int obj; screen = p = GetDstScreen(); for (x = 0; x < SCREEN_MEMSIZE; x++) p[x] = tableGreen[p[x] & 0xFF]; screen += MAP_YOFFS * SCREEN_WIDTH + MAP_XOFFS; for (y = 0; y < YMAX; y++) for (i = 0; i < MAP_FACTOR; i++) { for (x = 0; x < XMAX; x++) if (AutoMap(x, y) || showAll) { tile = &Map(x, y); for (j = 0; j < MAP_FACTOR; j++) if ((tile->flags & IS_WALL) != 0) *screen++ = WALL_COLOR; else if ((tile->flags & NO_WALK) != 0) *screen++ = DoorColor(x, y); else *screen++ = FLOOR_COLOR; } else screen += MAP_FACTOR; screen += SCREEN_WIDTH - XMAX * MAP_FACTOR; } for (y = 0; y < YMAX; y++) for (x = 0; x < XMAX; x++) { t = Map(x, y).things; while (t) { if ((t->flags & TILEITEM_OBJECTIVE) != 0) { obj = ObjectiveFromTileItem(t-> flags); if ((gMission.missionData-> objectives[obj]. flags & OBJECTIVE_HIDDEN) == 0 || showAll) { if ((gMission.missionData-> objectives[obj]. flags & OBJECTIVE_POSKNOWN) != 0 || AutoMap(x, y) || showAll) DisplayObjective(t, obj); } } else if (t->kind == KIND_OBJECT && t->data && AutoMap(x, y)) { TObject *o = t->data; if (o->objectIndex == OBJ_KEYCARD_RED) DrawDot(t, RED_DOOR_COLOR); else if (o->objectIndex == OBJ_KEYCARD_BLUE) DrawDot(t, BLUE_DOOR_COLOR); else if (o->objectIndex == OBJ_KEYCARD_GREEN) DrawDot(t, GREEN_DOOR_COLOR); else if (o->objectIndex == OBJ_KEYCARD_YELLOW) DrawDot(t, YELLOW_DOOR_COLOR); } t = t->next; } } DisplayPlayer(gPlayer1); DisplayPlayer(gPlayer2); DisplayExit(); DisplaySummary(); CopyToScreen(); if (!showAll) { do { cmd1 = cmd2 = 0; GetPlayerCmd(gPlayer1 ? &cmd1 : NULL, gPlayer2 ? &cmd2 : NULL); } while (((cmd1 | cmd2) & CMD_BUTTON3) != 0 || KeyDown(gOptions.mapKey)); memset(GetDstScreen(), 0, SCREEN_MEMSIZE); } }