2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation, either version 3 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ////////////////////////////////////////////////////////////////////////////////
26 FrameCB frameCB
= NULL
;
31 ////////////////////////////////////////////////////////////////////////////////
32 static Uint32
cbFrameTimer (Uint32 interval
, void *param
) {
35 evt
.type
= SDL_USEREVENT
;
37 //evt.user.type = SDL_USEREVENT;
39 evt.user.data1 = NULL;
40 evt.user.data2 = NULL;
43 //fprintf(stderr, "!\n");
48 // <0: quit; >0: new frame
49 static int processEvents (void) {
52 while (SDL_WaitEvent(&event
)) {
54 case SDL_QUIT
: // the user want to quit
58 if (event
.key
.keysym
.sym
== SDLK_F12
) return -1; // quit
59 if (keyCB
) keyCB(&event
.key
);
62 //while (SDL_PollEvent(NULL)) processEvents();
67 if (!vmIsThreadAlive(0)) return -1; // main thread is dead
72 static void buildFrame (void) {
75 lockSurface(&lock
, screen
);
76 if (frameCB
) frameCB(screen
);
82 void mainLoop (void) {
83 SDL_TimerID frameTimer
= SDL_AddTimer(25, cbFrameTimer
, NULL
);
88 if (!vmPaused
) vmExecuteAll();
91 eres
= processEvents();
93 SDL_RemoveTimer(frameTimer
);