Click here to Skip to main content
15,848,252 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: reference question Pin
Richard MacCutchan6-Jun-22 1:52
mveRichard MacCutchan6-Jun-22 1:52 
Questionmath Pin
Calin Negru4-Jun-22 21:13
Calin Negru4-Jun-22 21:13 
AnswerRe: math Pin
Victor Nijegorodov4-Jun-22 21:42
Victor Nijegorodov4-Jun-22 21:42 
AnswerRe: math Pin
Richard MacCutchan4-Jun-22 22:10
mveRichard MacCutchan4-Jun-22 22:10 
GeneralRe: math Pin
Calin Negru4-Jun-22 23:03
Calin Negru4-Jun-22 23:03 
GeneralRe: math Pin
Richard MacCutchan4-Jun-22 23:10
mveRichard MacCutchan4-Jun-22 23:10 
GeneralRe: math Pin
Calin Negru5-Jun-22 0:04
Calin Negru5-Jun-22 0:04 
QuestionGame loop and time measurement. Pin
Member 152127684-Jun-22 6:23
Member 152127684-Jun-22 6:23 
There is the function `Sys_Milliseconds`:

    <pre>int	curtime;
    int Sys_Milliseconds (void)
    {
    	static int		base;
    	static qboolean	initialized = false;
    
    	if (!initialized)
    	{	// let base retain 16 bits of effectively random data
    		base = timeGetTime() & 0xffff0000;
    		initialized = true;
    	}
    	curtime = timeGetTime() - base;
    
    	return curtime;
    }


Used in time calculation in the Quake 2 main game loop implementation:

//...
    oldtime = Sys_Milliseconds();
    //...
    while (1) {
    		//...
    
    		while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
    			if (!GetMessage(&msg, NULL, 0, 0))
    				Com_Quit();
    			sys_msg_time = msg.time;
    			TranslateMessage(&msg);
    			DispatchMessage(&msg);
    		}
    
    		do {
    			newtime = Sys_Milliseconds();    			
    			time = newtime - oldtime;
    		} while (time < 1);
    //...
    }




I'm wondering about the usage of the `Sys_Milliseconds` at all. What's the point in `base = timeGetTime() & 0xffff0000` line? Why are they applying the 0xffff0000 mask on the retrieved time? Why not just use the `timeGetTime` function directly:

//...
    oldtime = timeGetTime();
    //...
    while (1) {
    		//...
    
    		while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
    			if (!GetMessage(&msg, NULL, 0, 0))
    				Com_Quit();
    			sys_msg_time = msg.time;
    			TranslateMessage(&msg);
    			DispatchMessage(&msg);
    		}
    
    		do {
    			newtime = timeGetTime();    			
    			time = newtime - oldtime;
    		} while (time < 1);
    //...
    }

AnswerRe: Game loop and time measurement. Pin
Mircea Neacsu4-Jun-22 8:47
Mircea Neacsu4-Jun-22 8:47 
AnswerRe: Game loop and time measurement. Pin
Calin Negru4-Jun-22 11:43
Calin Negru4-Jun-22 11:43 
QuestionCollege Project Visual Enhancement Pin
Tomás Temperley2-Jun-22 16:31
Tomás Temperley2-Jun-22 16:31 
AnswerRe: College Project Visual Enhancement Pin
Richard MacCutchan2-Jun-22 22:48
mveRichard MacCutchan2-Jun-22 22:48 
GeneralRe: College Project Visual Enhancement Pin
Tomás Temperley3-Jun-22 11:24
Tomás Temperley3-Jun-22 11:24 
GeneralRe: College Project Visual Enhancement Pin
Richard MacCutchan3-Jun-22 23:17
mveRichard MacCutchan3-Jun-22 23:17 
QuestionAdd a context menu item in Windows Explorer (C/C++, no MFC) Pin
Derell Licht1-Jun-22 17:53
professionalDerell Licht1-Jun-22 17:53 
AnswerRe: Add a context menu item in Windows Explorer (C/C++, no MFC) Pin
Victor Nijegorodov1-Jun-22 21:29
Victor Nijegorodov1-Jun-22 21:29 
GeneralRe: Add a context menu item in Windows Explorer (C/C++, no MFC) Pin
Derell Licht2-Jun-22 5:41
professionalDerell Licht2-Jun-22 5:41 
GeneralRe: Add a context menu item in Windows Explorer (C/C++, no MFC) Pin
Dave Kreskowiak2-Jun-22 6:38
mveDave Kreskowiak2-Jun-22 6:38 
GeneralRe: Add a context menu item in Windows Explorer (C/C++, no MFC) Pin
Derell Licht2-Jun-22 6:50
professionalDerell Licht2-Jun-22 6:50 
GeneralRe: Add a context menu item in Windows Explorer (C/C++, no MFC) Pin
Dave Kreskowiak2-Jun-22 6:52
mveDave Kreskowiak2-Jun-22 6:52 
QuestionListbox items disappear Pin
ForNow31-May-22 18:05
ForNow31-May-22 18:05 
AnswerRe: Listbox items disappear Pin
Richard MacCutchan31-May-22 22:33
mveRichard MacCutchan31-May-22 22:33 
GeneralRe: Listbox items disappear Pin
ForNow1-Jun-22 13:17
ForNow1-Jun-22 13:17 
GeneralRe: Listbox items disappear Pin
Victor Nijegorodov1-Jun-22 21:17
Victor Nijegorodov1-Jun-22 21:17 
GeneralRe: Listbox items disappear Pin
Richard MacCutchan2-Jun-22 2:37
mveRichard MacCutchan2-Jun-22 2:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.