Skip to content
Archive of entries posted on January 2010

Implementing AntSnes with Qt part 3: Running the emulation in worker thread

I decided to build a two threaded application.  The main thread is for the UI, and the worker thread if for the emulator. This makes all porting easier in general, since now we can have a UI thread to handle all rendering, key I/O etc, and run the emulator thread as worker thread, which can emit the new processed frames to the UI thread etc.

The Qt makes the threading extra easy:
In my application I just inherited the emulator controller class from QThread,  then I just call start() to start the thread. The QThread will guarantee that  all slots will be executed in the context of that QThread after start has been called.
Another nice trick is to use Qt::BlockingQueuedConnection as connection type when the signal must be prosessed before the emitting thread can continue.

I’m really excited that all this communication between threads was so easy. No mutexes, or semaphores were required this time  at all :)

Here’s some code snippets how the threading was actually implemented.

//starting the thread
void QSnesController::Start()
{
   start( QThread::LowPriority );
}

//after the start() the thread will execute in the run()
void QSnesController::run()
 {
 connect(this, SIGNAL(frameblit()), blitter, SLOT(render()),
 Qt::BlockingQueuedConnection );

 gameloop();
 disconnect(this, SIGNAL(frameblit()), blitter, SLOT(render()) );
 }

//in render frame callback function
emit( frameblit() );

Implementing AntSnes with Qt part 2: Creating Settings View

I’m using the Qt now, so I wanted to make a new fresh clean look to the UI.  Therefore I dumped the old S60 UI style, which really wasn’t good design for touch devices.

You can see my settings view in the picture below. The empty space on top of the view is for the Main/settings widget. The main widget which is empty in the picture will have a  AntSnes logo, and maybe a screencapture from the currently selected saved state, which could be shown on top of the savestate box.  When user click some settings button such as controls/video/audio the main widget will change to show  selected settings.

AntSnes settings view

AtnSnes Settings view

On upper panel there’s obious selections for “Load ROM”, reset, and continue. On application startup, you can just press continue to continue playing the previous game you were playing on last time.

Continue reading ‘Implementing AntSnes with Qt part 2: Creating Settings View’ »

Implementing AntSnes with Qt part 1: Creating Views

This is first post on Qt App development series on Symbian. In this series I will describe how I made a new user interface with Qt for AntSnes. The same Ui will be later be used with gpsp and psx4all.

The mobile UI should be pretty much different, than the desktop UI, so there are some challenges ahed. I’m still sure that the UI will be a lot cooler than the old AntSnes UI with Symbian Avkon layer.

The UI will made with two separate views. The emulation view, and the settings view. The are both inherited from the QMainWidget, and they both are controlled by viewcontroller-class.  The ViewController is only responsible to call hide() and show() functions to widgets, so there’s allways the correct view shown on the screen.

Here’s an example how the app is started with the viewcontroller class.

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    ViewController* vc = new ViewController();
    return a.exec();
}

Continue reading ‘Implementing AntSnes with Qt part 1: Creating Views’ »