X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_em%2Finput.c;h=79efd2f93eeceb0379f412e81c1da31930bffcca;hb=f47cd4b09952aaf95d16542f6b53f2d8bf9e1d7d;hp=86feeb4d3e54acfaf7d3281ceb3ad85a183c3330;hpb=2362e426463cb445e119a4e3e5ce0b6ccb3fb33c;p=rocksndiamonds.git diff --git a/src/game_em/input.c b/src/game_em/input.c index 86feeb4d..79efd2f9 100644 --- a/src/game_em/input.c +++ b/src/game_em/input.c @@ -3,25 +3,11 @@ * handle input from x11 and keyboard and joystick */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "global.h" #include "display.h" #include "level.h" -#if defined(TARGET_X11) - unsigned long Random; struct PLAYER ply1; @@ -38,6 +24,9 @@ unsigned short **Draw; static unsigned short *Index[4][HEIGHT]; static unsigned short Array[4][HEIGHT][WIDTH]; +extern unsigned int screen_x; +extern unsigned int screen_y; + void game_init_vars(void) { int x, y; @@ -82,7 +71,15 @@ void InitGameEngine_EM() void GameActions_EM(byte action) { - input_eventloop(); + static unsigned long game_frame_delay = 0; + unsigned long game_frame_delay_value = getGameFrameDelay_EM(25); + +#if 0 + /* this is done in screens.c/HandleGameActions() by calling BackToFront() */ + XSync(display, False); /* block until all graphics are drawn */ +#endif + + WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value); game_animscreen(); @@ -92,6 +89,8 @@ void GameActions_EM(byte action) readjoy(action); + UpdateEngineValues(screen_x / TILEX, screen_y / TILEY); + if (frame == 7) { synchro_1(); @@ -139,36 +138,3 @@ void readjoy(byte action) ply1.joy_w = west; } } - - -/* handle events from x windows and block until the next frame */ - -void input_eventloop(void) -{ - static struct timeval tv1 = { 0, 0 }; - static struct timeval tv2 = { 0, 0 }; - unsigned long count; - - XSync(display, False); /* block until all graphics are drawn */ - - if (gettimeofday(&tv2, 0) == -1) - tv2.tv_usec = 0; - - count = tv2.tv_usec + 1000000 - tv1.tv_usec; - if (count >= 1000000) - count -= 1000000; - - tv1.tv_usec = tv2.tv_usec; - if (count < 25000) - { - tv2.tv_sec = 0; - tv2.tv_usec = 25000 - count; -#if 1 - select(0, 0, 0, 0, &tv2); /* sleep a bit */ -#else - usleep(tv2.tv_usec); -#endif - } -} - -#endif