Click here to Skip to main content
15,891,431 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: reference question Pin
Richard MacCutchan6-Jun-22 0:52
mveRichard MacCutchan6-Jun-22 0:52 
Questionmath Pin
Calin Negru4-Jun-22 20:13
Calin Negru4-Jun-22 20:13 
AnswerRe: math Pin
Victor Nijegorodov4-Jun-22 20:42
Victor Nijegorodov4-Jun-22 20:42 
AnswerRe: math Pin
Richard MacCutchan4-Jun-22 21:10
mveRichard MacCutchan4-Jun-22 21:10 
GeneralRe: math Pin
Calin Negru4-Jun-22 22:03
Calin Negru4-Jun-22 22:03 
GeneralRe: math Pin
Richard MacCutchan4-Jun-22 22:10
mveRichard MacCutchan4-Jun-22 22:10 
GeneralRe: math Pin
Calin Negru4-Jun-22 23:04
Calin Negru4-Jun-22 23:04 
QuestionGame loop and time measurement. Pin
Member 152127684-Jun-22 5:23
Member 152127684-Jun-22 5: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 7:47
Mircea Neacsu4-Jun-22 7:47 
AnswerRe: Game loop and time measurement. Pin
Calin Negru4-Jun-22 10:43
Calin Negru4-Jun-22 10:43 
QuestionCollege Project Visual Enhancement Pin
Tomás Temperley2-Jun-22 15:31
Tomás Temperley2-Jun-22 15:31 
AnswerRe: College Project Visual Enhancement Pin
Richard MacCutchan2-Jun-22 21:48
mveRichard MacCutchan2-Jun-22 21:48 
GeneralRe: College Project Visual Enhancement Pin
Tomás Temperley3-Jun-22 10:24
Tomás Temperley3-Jun-22 10:24 
GeneralRe: College Project Visual Enhancement Pin
Richard MacCutchan3-Jun-22 22:17
mveRichard MacCutchan3-Jun-22 22:17 
QuestionAdd a context menu item in Windows Explorer (C/C++, no MFC) Pin
Derell Licht1-Jun-22 16:53
professionalDerell Licht1-Jun-22 16:53 
AnswerRe: Add a context menu item in Windows Explorer (C/C++, no MFC) Pin
Victor Nijegorodov1-Jun-22 20:29
Victor Nijegorodov1-Jun-22 20:29 
GeneralRe: Add a context menu item in Windows Explorer (C/C++, no MFC) Pin
Derell Licht2-Jun-22 4:41
professionalDerell Licht2-Jun-22 4:41 
GeneralRe: Add a context menu item in Windows Explorer (C/C++, no MFC) Pin
Dave Kreskowiak2-Jun-22 5:38
mveDave Kreskowiak2-Jun-22 5:38 
GeneralRe: Add a context menu item in Windows Explorer (C/C++, no MFC) Pin
Derell Licht2-Jun-22 5:50
professionalDerell Licht2-Jun-22 5:50 
GeneralRe: Add a context menu item in Windows Explorer (C/C++, no MFC) Pin
Dave Kreskowiak2-Jun-22 5:52
mveDave Kreskowiak2-Jun-22 5:52 
QuestionListbox items disappear Pin
ForNow31-May-22 17:05
ForNow31-May-22 17:05 
AnswerRe: Listbox items disappear Pin
Richard MacCutchan31-May-22 21:33
mveRichard MacCutchan31-May-22 21:33 
GeneralRe: Listbox items disappear Pin
ForNow1-Jun-22 12:17
ForNow1-Jun-22 12:17 
GeneralRe: Listbox items disappear Pin
Victor Nijegorodov1-Jun-22 20:17
Victor Nijegorodov1-Jun-22 20:17 
GeneralRe: Listbox items disappear Pin
Richard MacCutchan2-Jun-22 1:37
mveRichard MacCutchan2-Jun-22 1: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.