11 ////////////////////////////////////////////////////////////////////////////////
12 FrameCB frameCB
= NULL
;
17 ////////////////////////////////////////////////////////////////////////////////
18 static Uint32
cbFrameTimer (Uint32 interval
, void *param
) {
21 evt
.type
= SDL_USEREVENT
;
23 //evt.user.type = SDL_USEREVENT;
25 evt.user.data1 = NULL;
26 evt.user.data2 = NULL;
29 //fprintf(stderr, "!\n");
34 // <0: quit; >0: new frame
35 static int processEvents (void) {
38 while (SDL_WaitEvent(&event
)) {
40 case SDL_QUIT
: // the user want to quit
44 if (event
.key
.keysym
.sym
== SDLK_F12
) return -1; // quit
45 if (keyCB
) keyCB(&event
.key
);
48 //while (SDL_PollEvent(NULL)) processEvents();
53 if (!vmIsThreadAlive(0)) return -1; // main thread is dead
58 static void buildFrame (void) {
61 lockSurface(&lock
, screen
);
62 if (frameCB
) frameCB(screen
);
68 void mainLoop (void) {
69 SDL_TimerID frameTimer
= SDL_AddTimer(25, cbFrameTimer
, NULL
);
74 if (!vmPaused
) vmExecuteAll();
77 eres
= processEvents();
79 SDL_RemoveTimer(frameTimer
);