frodo-wii/main.cpp

58 lines
947 B
C++
Raw Normal View History

2009-11-23 20:47:01 +01:00
#include <SDL_image.h>
#include <SDL_ttf.h>
2009-12-06 10:11:04 +01:00
#include "gui.hh"
2009-11-23 19:52:30 +01:00
#include "utils.hh"
#include <C64.h>
2009-11-23 19:52:30 +01:00
SDL_Surface *screen;
C64 *TheC64;
2009-11-23 19:52:30 +01:00
2010-01-16 09:56:15 +01:00
#define MS_PER_FRAME 28
2009-11-23 19:52:30 +01:00
static void run(void)
{
2010-01-16 09:56:15 +01:00
Uint32 last_frame = SDL_GetTicks();
2009-11-23 19:52:30 +01:00
while(1)
{
SDL_Event ev;
2010-01-16 09:56:15 +01:00
Uint32 now = SDL_GetTicks();
while (SDL_PollEvent(&ev)) {
2009-11-23 19:52:30 +01:00
if (ev.type == SDL_QUIT)
2009-11-23 20:47:01 +01:00
exit(1);
2009-11-23 19:52:30 +01:00
Gui::gui->pushEvent(&ev);
2009-11-23 19:52:30 +01:00
}
Gui::gui->runLogic();
Gui::gui->draw(screen);
2009-11-23 19:52:30 +01:00
2009-11-23 20:33:51 +01:00
SDL_Flip(screen);
2010-01-16 09:56:15 +01:00
if ( (now - last_frame) < MS_PER_FRAME)
SDL_Delay( MS_PER_FRAME - (now - last_frame));
2009-11-23 19:52:30 +01:00
}
}
static void init(void)
{
/* Creation of the mocks */
TheC64 = new C64();
2009-11-23 19:52:30 +01:00
screen = SDL_SetVideoMode(640, 480, 16,
SDL_DOUBLEBUF);
panic_if(!screen, "Cannot initialize video: %s\n", SDL_GetError());
TTF_Init();
Gui::init();
Gui::gui->activate();
2009-11-23 19:52:30 +01:00
}
2009-11-19 18:59:43 +01:00
int main(int argc, char *argv[])
{
2009-11-23 19:52:30 +01:00
init();
run();
2009-11-19 18:59:43 +01:00
return 0;
}