Exemplo n.º 1
0
void H2_GameLoop(void)
{
    if (M_CheckParm("-debugfile"))
    {
        char filename[20];
        M_snprintf(filename, sizeof(filename), "debug%i.txt", consoleplayer);
        debugfile = fopen(filename, "w");
    }
    I_SetWindowTitle(gamedescription);
    I_GraphicsCheckCommandLine();
    I_SetGrabMouseCallback(D_GrabMouseCallback);
    I_InitGraphics();

    while (1)
    {
        // Frame syncronous IO operations
        I_StartFrame();

        // Process one or more tics
        // Will run at least one tic
        TryRunTics();

        // Move positional sounds
        S_UpdateSounds(players[displayplayer].mo);

        DrawAndBlit();
    }
}
Exemplo n.º 2
0
void __fastcall run_game_loop(int uMsg)
{
	//int v3; // eax
	bool v5; // zf
	//int v6; // eax
	signed int v7; // [esp+8h] [ebp-24h]
	LRESULT (__stdcall *saveProc)(HWND, UINT, WPARAM, LPARAM); // [esp+Ch] [ebp-20h]
	struct tagMSG msg; // [esp+10h] [ebp-1Ch]

	nthread_ignore_mutex(1);
	start_game(uMsg);
	saveProc = SetWindowProc(GM_Game);
	control_update_life_mana();
	msg_process_net_packets();
	gbRunGame = 1;
	gbProcessPlayers = 1;
	gbRunGameResult = 1;
	drawpanflag = 255;
	DrawAndBlit();
	PaletteFadeIn(8);
	drawpanflag = 255;
	gbGameLoopStartup = 1;
	nthread_ignore_mutex(0);
	while ( gbRunGame )
	{
		diablo_color_cyc_logic();
		if ( PeekMessageA(&msg, NULL, 0, 0, PM_NOREMOVE) )
		{
			SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
			while ( PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE) )
			{
				if ( msg.message == WM_QUIT )
				{
					gbRunGameResult = 0;
					gbRunGame = 0;
					break;
				}
				TranslateMessage(&msg);
				DispatchMessageA(&msg);
			}
			if ( !gbRunGame || (v7 = 1, !nthread_has_500ms_passed()) )
				v7 = 0;
			SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
			v5 = v7 == 0;
		}
		else
		{
			//_LOBYTE(v6) = nthread_has_500ms_passed();
			v5 = nthread_has_500ms_passed() == 0;
		}
		if ( !v5 )
		{
			multi_process_network_packets();
			game_loop(gbGameLoopStartup);
			msgcmd_send_chat();
			gbGameLoopStartup = 0;
			DrawAndBlit();
		}
#ifdef SLEEP
		Sleep(1);
#endif
	}
	if ( (unsigned char)gbMaxPlayers > 1u )
		pfile_write_hero();
	pfile_flush_W();
	PaletteFadeOut(8);
	SetCursor(0);
	ClearScreenBuffer();
	drawpanflag = 255;
	scrollrt_draw_game_screen(1);
	SetWindowProc(saveProc);
	free_game();
	if ( cineflag )
	{
		cineflag = 0;
		DoEnding();
	}
}