static void DrawFileStrings (MELEE_STATE *pMS) { POINT origin; CONTEXT OldContext; origin.x = FILE_STRING_ORIGIN_X; origin.y = FILE_STRING_ORIGIN_Y; OldContext = SetContext (SpaceContext); SetContextFont (MicroFont); BatchGraphics (); DrawMeleeIcon (28); /* The load team frame */ if (FillFileView (pMS)) { COUNT i; for (i = pMS->load.top; i < pMS->load.bot; i++) { DrawFileString (pMS->load.view[i - pMS->load.top], &origin, TRUE, FALSE); origin.y += ENTRY_HEIGHT; } } UnbatchGraphics (); SetContext (OldContext); }
/// <summary> /// Remove existing hardware breakpoint /// </summary> /// <param name="ptr">Breakpoint address</param> /// <returns>true on success</returns> bool Thread::RemoveHWBP( ptr_t ptr ) { _CONTEXT64 context64 = { 0 }; _CONTEXT32 context32 = { 0 }; bool use64 = !_core->native()->GetWow64Barrier().x86OS; bool res = use64 ? GetContext( context64, CONTEXT64_DEBUG_REGISTERS, true ) : GetContext( context32, CONTEXT_DEBUG_REGISTERS, true ); auto pDR7 = use64 ? reinterpret_cast<regDR7*>(&context64.Dr7) : reinterpret_cast<regDR7*>(&context32.Dr7); if (!res) return false; // Search for breakpoint for (int i = 0; i < 4; i++) { if ((&context64.Dr0)[i] == ptr || (&context32.Dr0)[i] == static_cast<DWORD>(ptr)) { use64 ? *(&context64.Dr0 + i) = 0 : *(&context32.Dr0 + i) = 0; pDR7->setLocal( i, 0 ); pDR7->setLen( i, 0 ); pDR7->setRW( i, 0 ); if (pDR7->empty()) pDR7->l_enable = 0; return use64 ? SetContext( context64 ) : SetContext( context32 ); } } return false; }
// Create a frame for each player to display their current fleet in, // to be used when selecting the next ship to fight with. void BuildPickMeleeFrame (void) { STAMP s; CONTEXT OldContext = SetContext (OffScreenContext); if (PickMeleeFrame) DestroyDrawable (ReleaseDrawable (PickMeleeFrame)); PickMeleeFrame = CaptureDrawable (CreateDrawable ( WANT_PIXMAP, MELEE_WIDTH, MELEE_HEIGHT, 2)); s.origin.x = 0; s.origin.y = 0; s.frame = CaptureDrawable (LoadGraphic (MELEE_PICK_MASK_PMAP_ANIM)); SetContextFGFrame (PickMeleeFrame); DrawStamp (&s); s.frame = IncFrameIndex (s.frame); SetContextFGFrame (IncFrameIndex (PickMeleeFrame)); DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); SetContext (OldContext); }
void DrawCargoStrings (BYTE OldElement, BYTE NewElement) { CONTEXT OldContext; OldContext = SetContext (StatusContext); SetContextFont (TinyFont); BatchGraphics (); if (OldElement > NUM_ELEMENT_CATEGORIES) { // Asked for the initial display DrawCargoDisplay (); // do not draw unselected again this time OldElement = NewElement; } if (OldElement != NewElement) { // unselect the previous element DrawElementAmount (OldElement, false); } if (NewElement != (BYTE)~0) { // select the new element DrawElementAmount (NewElement, true); } UnbatchGraphics (); SetContext (OldContext); }
/// <summary> /// Add hardware breakpoint to thread /// </summary> /// <param name="addr">Breakpoint address</param> /// <param name="type">Breakpoint type(read/write/execute)</param> /// <param name="length">Number of bytes to include into breakpoint</param> /// <returns>Index of used breakpoint; -1 if failed</returns> int Thread::AddHWBP( ptr_t addr, HWBPType type, HWBPLength length ) { _CONTEXT64 context64 = { 0 }; _CONTEXT32 context32 = { 0 }; bool use64 = !_core->native()->GetWow64Barrier().x86OS; // CONTEXT_DEBUG_REGISTERS can be operated without thread suspension bool res = use64 ? GetContext( context64, CONTEXT64_DEBUG_REGISTERS, true ) : GetContext( context32, CONTEXT_DEBUG_REGISTERS, true ); auto pDR7 = use64 ? reinterpret_cast<regDR7*>(&context64.Dr7) : reinterpret_cast<regDR7*>(&context32.Dr7); if (!res) return -1; // Get free DR int freeIdx = pDR7->getFreeIndex(); // If all 4 registers are occupied - error if (freeIdx < 0) { LastNtStatus( STATUS_NO_MORE_ENTRIES ); return -1; } // Enable corresponding HWBP and local BP flag pDR7->l_enable = 1; pDR7->setLocal( freeIdx, 1 ); pDR7->setRW( freeIdx, static_cast<char>(type) ); pDR7->setLen( freeIdx, static_cast<char>(length) ); use64 ? *(&context64.Dr0 + freeIdx) = addr : *(&context32.Dr0 + freeIdx) = static_cast<DWORD>(addr); // Write values to registers res = use64 ? SetContext( context64, true ) : SetContext( context32, true ); return res ? freeIdx : -1; }
static void on_input_frame (void) { CONTEXT oldContext; oldContext = SetContext (SpaceContext); animatePowerLines (NULL); SetContext (oldContext); }
static void DrawOrbitalDisplay (DRAW_ORBITAL_MODE Mode) { RECT r; SetContext (SpaceContext); GetContextClipRect (&r); BatchGraphics (); if (Mode != DRAW_ORBITAL_UPDATE) { SetTransitionSource (NULL); DrawSISFrame (); DrawSISMessage (NULL); DrawSISTitle (GLOBAL_SIS (PlanetName)); DrawStarBackGround (); DrawPlanetSurfaceBorder (); } if (Mode == DRAW_ORBITAL_WAIT) { STAMP s; SetContext (GetScanContext (NULL)); s.frame = CaptureDrawable (LoadGraphic (ORBENTER_PMAP_ANIM)); s.origin.x = -SAFE_X; s.origin.y = 0; DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); } else if (Mode == DRAW_ORBITAL_FULL) { DrawDefaultPlanetSphere (); } if (Mode != DRAW_ORBITAL_WAIT) { SetContext (GetScanContext (NULL)); DrawPlanet (0, BLACK_COLOR); } if (Mode != DRAW_ORBITAL_UPDATE) { ScreenTransition (3, &r); } UnbatchGraphics (); // for later RepairBackRect() // JMS_GFX if (RESOLUTION_FACTOR == 0) LoadIntoExtraScreen (&r); else LoadIntoExtraScreen_Fs (&r); }
// draws the oscilloscope void DrawOscilloscope (void) { STAMP s; BYTE scope_data[128]; if (oscillDisabled) return; assert ((size_t)scopeSize.width <= sizeof scope_data); assert (scopeSize.height < 256); if (GraphForegroundStream (scope_data, scopeSize.width, scopeSize.height)) { int i; CONTEXT oldContext; oldContext = SetContext (OffScreenContext); SetContextFGFrame (scopeWork); SetContextClipRect (NULL); // draw the background image s.origin.x = 0; s.origin.y = 0; s.frame = scope_frame; DrawStamp (&s); // draw the scope lines SetContextForeGroundColor (scopeColor); for (i = 0; i < scopeSize.width - 1; ++i) { LINE line; line.first.x = i + 1; line.first.y = scope_data[i] + 1; line.second.x = i + 2; line.second.y = scope_data[i + 1] + 1; DrawLine (&line); } SetContext (oldContext); s.frame = scopeWork; } else { // no data -- draw blank scope background s.frame = scope_frame; } // draw the final scope image to screen s.origin.x = 0; s.origin.y = 0; DrawStamp (&s); }
static void putScreen (FRAME savedFrame) { STAMP stamp; CONTEXT oldContext = SetContext (ScreenContext); stamp.origin.x = 0; stamp.origin.y = 0; stamp.frame = savedFrame; DrawStamp (&stamp); (void) SetContext (oldContext); }
BOOLEAN DoSaveTeam (MELEE_STATE *pMS) { STAMP MsgStamp; char file[NAME_MAX]; uio_Stream *stream; CONTEXT OldContext; bool saveOk = false; snprintf (file, sizeof file, "%s.mle", MeleeSetup_getTeamName (pMS->meleeSetup, pMS->side)); LockMutex (GraphicsLock); OldContext = SetContext (ScreenContext); ConfirmSaveLoad (&MsgStamp); // Show the "Saving . . ." message. UnlockMutex (GraphicsLock); stream = uio_fopen (meleeDir, file, "wb"); if (stream != NULL) { saveOk = (MeleeTeam_serialize (&pMS->meleeSetup->teams[pMS->side], stream) == 0); uio_fclose (stream); if (!saveOk) uio_unlink (meleeDir, file); } pMS->load.top = 0; pMS->load.cur = 0; // Undo the screen damage done by the "Saving . . ." message. LockMutex (GraphicsLock); DrawStamp (&MsgStamp); DestroyDrawable (ReleaseDrawable (MsgStamp.frame)); SetContext (OldContext); UnlockMutex (GraphicsLock); if (!saveOk) SaveProblem (); // Update the team list; a previously existing team may have been // deleted when save failed. LoadTeamList (pMS); SelectTeamByFileName (pMS, file); return (stream != 0); }
// Pre: caller holds the graphics lock. static void DrawPickMeleeFrame (COUNT which_player) { CONTEXT oldContext; STAMP s; oldContext = SetContext (SpaceContext); s.frame = SetAbsFrameIndex (PickMeleeFrame, which_player); s.origin.x = PICK_X_OFFS - RES_SCALE(3); // JMS_GFX s.origin.y = PICK_Y_OFFS - RES_SCALE(9) + ((1 - which_player) * PICK_SIDE_OFFS); DrawStamp (&s); // Draw the selection box to screen. SetContext (oldContext); }
static void describeContext (FILE *out, const CONTEXT context) { RECT rect; CONTEXT oldContext = SetContext (context); GetContextClipRect (&rect); fprintf(out, "Context '%s':\n" "\tClipRect = (%d, %d)-(%d, %d) (%d x %d)\n", GetContextName (context), rect.corner.x, rect.corner.y, rect.corner.x + rect.extent.width, rect.corner.y + rect.extent.height, rect.extent.width, rect.extent.height); SetContext (oldContext); }
// Returns true iff this context has a visible FRAME. static bool isContextVisible (CONTEXT context) { FRAME contextFrame; // Save the original context. CONTEXT oldContext = SetContext (context); // Get the frame of the specified context. contextFrame = GetContextFGFrame (); // Restore the original context. SetContext (oldContext); return contextFrame == Screen; }
static void DrawRestartMenu (BYTE OldState, BYTE NewState, FRAME f) { RECT r; TEXT t; UNICODE buf[64]; LockMutex (GraphicsLock); SetContext (ScreenContext); r.corner.x = r.corner.y = r.extent.width = r.extent.height = 0; SetContextClipRect (&r); r.corner.x = 0; r.corner.y = 0; r.extent.width = SCREEN_WIDTH; r.extent.height = SCREEN_HEIGHT; SetFlashRect (&r, SetAbsFrameIndex (f, NewState + 1)); // Put version number in the corner SetContextFont (TinyFont); t.pStr = buf; t.baseline.x = SCREEN_WIDTH - 3; t.baseline.y = SCREEN_HEIGHT - 2; t.align = ALIGN_RIGHT; t.CharCount = (COUNT)~0; sprintf (buf, "v%d.%d.%d%s", UQM_MAJOR_VERSION, UQM_MINOR_VERSION, UQM_PATCH_VERSION, UQM_EXTRA_VERSION); SetContextForeGroundColor (WHITE_COLOR); font_DrawText (&t); UnlockMutex (GraphicsLock); (void) OldState; /* Satisfying compiler (unused parameter) */ }
void InitSISContexts (void) { RECT r; SetContext (StatusContext); SetContext (SpaceContext); SetContextFGFrame (Screen); r.corner.x = SIS_ORG_X; r.corner.y = SIS_ORG_Y; r.extent.width = SIS_SCREEN_WIDTH; r.extent.height = SIS_SCREEN_HEIGHT; SetContextClipRect (&r); }
// Maybe move to elsewhere, where it can be reused? static FRAME getScreen (void) { CONTEXT oldContext = SetContext (ScreenContext); FRAME savedFrame; RECT screenRect; screenRect.corner.x = 0; screenRect.corner.y = 0; screenRect.extent.width = ScreenWidth; screenRect.extent.height = ScreenHeight; savedFrame = CaptureDrawable (LoadDisplayPixmap (&screenRect, (FRAME) 0)); (void) SetContext (oldContext); return savedFrame; }
static void RosterCleanup (MENU_STATE *pMS) { if (pMS->flash_task) { UnlockMutex (GraphicsLock); ConcludeTask (pMS->flash_task); LockMutex (GraphicsLock); pMS->flash_task = 0; } if (pMS->CurFrame) { STAMP s; SHIP_FRAGMENT *StarShipPtr; SetContext (StatusContext); s.origin = pMS->first_item; StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), (HSHIPFRAG)pMS->CurFrame); s.frame = StarShipPtr->icons; UnlockShipFrag (&GLOBAL (built_ship_q), (HSHIPFRAG)pMS->CurFrame); if (!(pMS->CurState & SHIP_TOGGLE)) DrawStamp (&s); else { SetContextForeGroundColor (WHITE_COLOR); DrawFilledStamp (&s); } } }
void plNetMessage::InitReplyFieldsFrom(plNetMessage * msg) { bool hasContext = msg->GetHasContext(); SetHasContext(hasContext); if (hasContext) SetContext(msg->GetContext()); bool hasTransactionID = msg->GetHasTransactionID(); SetHasTransactionID(hasTransactionID); if (hasTransactionID) SetTransactionID(msg->GetTransactionID()); bool hasPlayerID = msg->GetHasPlayerID(); if ( hasPlayerID ) SetPlayerID( msg->GetPlayerID() ); bool hasAcctUUID = msg->GetHasAcctUUID(); if ( hasAcctUUID ) SetAcctUUID( msg->GetAcctUUID() ); bool hasTimeSent = msg->GetHasTimeSent(); if ( hasTimeSent ) SetTimeSent( msg->GetTimeSent() ); #if 0 // I don't think the version should be copied if (msg->IsBitSet(kHasVersion)) SetVersion(); #endif }
static void drawModifiedSupportShip (ROSTER_STATE *rosterState) { SetContext (StatusContext); SetContextForeGroundColor (ROSTER_MODIFY_SHIP_COLOR); drawSupportShip (rosterState, TRUE); }
void AlienTalkSegue (COUNT wait_track) { // this skips any talk segues that follow an aborted one if ((GLOBAL (CurrentActivity) & CHECK_ABORT) || TalkingFinished) return; if (!pCurInputState->Initialized) { InitSpeechGraphics (); SetColorMap (GetColorMapAddress (CommData.AlienColorMap)); SetContext (AnimContext); DrawAlienFrame (NULL, 0, TRUE); UpdateSpeechGraphics (); CommIntroTransition (); pCurInputState->Initialized = TRUE; PlayMusic (CommData.AlienSong, TRUE, 1); SetMusicVolume (BACKGROUND_VOL); InitCommAnimations (); LastActivity &= ~CHECK_LOAD; } TalkingFinished = TalkSegue (wait_track); if (TalkingFinished && !VolasPackPresent) FadeMusic (FOREGROUND_VOL, ONE_SECOND); }
static void FeedbackPlayerPhrase (UNICODE *pStr) { SetContext (SpaceContext); BatchGraphics (); DrawSISComWindow (); if (pStr[0]) { TEXT ct; ct.baseline.x = SIS_SCREEN_WIDTH >> 1; ct.baseline.y = SLIDER_Y + SLIDER_HEIGHT + RES_SCALE(13); // JMS_GFX ct.align = ALIGN_CENTER; ct.CharCount = (COUNT)~0; ct.pStr = GAME_STRING (FEEDBACK_STRING_BASE); // "(In response to your statement)" SetContextForeGroundColor (COMM_RESPONSE_INTRO_TEXT_COLOR); font_DrawText (&ct); ct.baseline.y += RES_SCALE(16); // JMS_GFX SetContextForeGroundColor (COMM_FEEDBACK_TEXT_COLOR); ct.pStr = pStr; add_text (-4, &ct); } UnbatchGraphics (); }
static void DrawDevices (DEVICES_STATE *devState, COUNT OldDevice, COUNT NewDevice) { LockMutex (GraphicsLock); BatchGraphics (); SetContext (StatusContext); if (OldDevice > NUM_DEVICES) { // Asked for the initial display or refresh DrawDevicesDisplay (devState); // do not draw unselected again this time OldDevice = NewDevice; } if (OldDevice != NewDevice) { // unselect the previous element DrawDevice (devState->list[OldDevice], OldDevice - devState->topIndex, false); } if (NewDevice < NUM_DEVICES) { // select the new element DrawDevice (devState->list[NewDevice], NewDevice - devState->topIndex, true); } UnbatchGraphics (); UnlockMutex (GraphicsLock); }
void InstrumentComposer::DropItem(CSoundComponent * comp) { if (activeContext) { activeContext->Add(comp); SetContext(activeContext); Update(); } }
static void UpdateSpeechGraphics (void) { static TimeCount NextTime; CONTEXT OldContext; if (GetTimeCounter () < NextTime) return; // too early NextTime = GetTimeCounter () + OSCILLOSCOPE_RATE; OldContext = SetContext (RadarContext); DrawOscilloscope (); SetContext (SpaceContext); DrawSlider (); SetContext (OldContext); }
static int hangar_anim_func (void *data) { DWORD TimeIn; STAMP s; Task task = (Task) data; COLORMAP ColorMap; RECT ClipRect; if (!pMenuState->CurString) { FinishTask (task); return -1; } s.origin.x = s.origin.y = 0; s.frame = SetAbsFrameIndex (pMenuState->CurFrame, 24); ClipRect = pMenuState->flash_rect1; ColorMap = SetAbsColorMapIndex (pMenuState->CurString, 0); TimeIn = GetTimeCounter (); while (!Task_ReadState (task, TASK_EXIT)) { CONTEXT OldContext; RECT OldClipRect; LockMutex (GraphicsLock); OldContext = SetContext (ScreenContext); GetContextClipRect (&OldClipRect); SetContextClipRect (&ClipRect); ColorMap = SetRelColorMapIndex (ColorMap, 1); SetColorMap (GetColorMapAddress (ColorMap)); DrawStamp (&s); SetContextClipRect (&OldClipRect); SetContext (OldContext); UnlockMutex (GraphicsLock); SleepThreadUntil (TimeIn + ONE_SECOND / HANGAR_ANIM_RATE); TimeIn = GetTimeCounter (); } FinishTask (task); return 0; }
CNCSJPCNode::Context *CNCSJPCResample::GetContext(ContextID nCtx, bool bAutoConstruct) { CNCSJPCNode::Context *pCtx = CNCSJPCNode::GetContext(nCtx, false); if(!pCtx && bAutoConstruct) { pCtx = new Context; SetContext(nCtx, pCtx); } return(pCtx); }
static void flashSupportShipCrew (void) { RECT r; SetContext (StatusContext); GetStatusMessageRect (&r); SetFlashRect (&r); }
void SplashScreen (void (* DoProcessing)(DWORD TimeOut)) { BYTE xform_buf[1]; STAMP s; DWORD TimeOut; BOOLEAN InputState; xform_buf[0] = FadeAllToBlack; SleepThreadUntil (XFormColorMap ( (COLORMAPPTR) xform_buf, ONE_SECOND / 120)); LockMutex (GraphicsLock); SetContext (ScreenContext); s.origin.x = s.origin.y = 0; s.frame = CaptureDrawable (LoadGraphic (TITLE_ANIM)); DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); UnlockMutex (GraphicsLock); xform_buf[0] = FadeAllToColor; TimeOut = XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2); if (DoProcessing) DoProcessing (TimeOut); if (GLOBAL (CurrentActivity) & CHECK_ABORT) { return; } /* There was a forcible setting of CHECK_ABORT here. I cannot * find any purpose for this that DoRestart doesn't handle * better (forcing all other threads but this one to quit out, * I believe), and have thus removed it. It was interfering * with the proper operation of the quit operation. * --Michael */ TimeOut += ONE_SECOND * 3; while (!(InputState = AnyButtonPress (FALSE)) && (GetTimeCounter () <= TimeOut) && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { TaskSwitch (); } if (GLOBAL (CurrentActivity) & CHECK_ABORT) { return; } GLOBAL (CurrentActivity) &= ~CHECK_ABORT; /* You can't try to quit during a fade to black, because if * you try, the confirmation window will fade to black too. * Fixing this will require a rewrite of our whole rendering * engine. -- Michael */ xform_buf[0] = FadeAllToBlack; SleepThreadUntil (XFormColorMap ((COLORMAPPTR)xform_buf, ONE_SECOND / 2)); }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- AI_Response::AI_Response( const AI_Response &from ) { Assert( (void*)(&m_Type) == (void*)this ); m_pCriteria = NULL; memcpy( this, &from, sizeof(*this) ); m_pCriteria = NULL; m_szContext = NULL; SetContext( from.m_szContext ); m_bApplyContextToWorld = from.m_bApplyContextToWorld; }
void WorldCursor::Setup(grip gContext) { Context *pContext; msgMask = E_MOUSE_DOWN | E_MOUSE_UP; fIsMouseDown = FALSE; // attach ourselves to context SetContext(gContext); SetRes(RES_ANIM,102,2); SetContext(gContext); SetPri(PRI_INTERFACE + 1); FindStart(); Guy::Setup(); pContext = ADerefAs(Context,gContext); pContext->CutObject(gSelf, CT_SERV); }