PCSX2 Documentation/The PCSX2 Program Flow: Difference between revisions

From PCSX2 Wiki
Jump to navigation Jump to search
Line 55: Line 55:


====EE Thread====
====EE Thread====
See [https://github.com/PCSX2/pcsx2/blob/d6ba55eebf0a117831197a00655df7d6518c71ab/pcsx2/DebugTools/BiosDebugData.h BiosDebugData.h]
(See [https://github.com/PCSX2/pcsx2/blob/d6ba55eebf0a117831197a00655df7d6518c71ab/pcsx2/DebugTools/BiosDebugData.h BiosDebugData.h])
Handles the Emotion Engine
Handles the Emotion Engine instructions.

Revision as of 16:57, 19 March 2015

The following article is a very general overview of the flow of the PCSX2 application.

AppMain.cpp - this is where the fun begins!

There is a lot that happens under the hood with wxWidgets. We don't need to worry about that. All we need to worry about is this this line of code:

in AppMain.cpp <source lang="cpp">IMPLEMENT_APP(Pcsx2App)</source>

This macro tells the wxWidgets framework that we want to fire up Pcsx2App. Easy, right?

Pcsx2App - the part we care about

Next, Let's take a look at this code here.

in App.h <source lang=cpp> class Pcsx2App : public wxAppWithHelpers{} </source>

You can see here that the Pcsx2App class is an extension of the wxAppWithHelpers class. WxWidgets applications are defined as classes, which are instantiated into an object when we start the program. Pcsx2App contains methods that wxWidgets is going to call upon at various times. So what gets called when we fire up Pcsx2App? That would be OnInit(). There's all kinds of crazy stuff happening there, but what we really care about is this line:

in AppInit.cpp <source lang="cpp"> if( m_UseGUI ) OpenMainFrame(); </source>

WxWidgets Frames

In addition to Application classes, there are also Frame classes. So when we call the OpenMainFrame function, what happens? Take a look at this code:

in pcsx2/gui/AppInit.cpp <source lang="cpp"> void Pcsx2App::OpenMainFrame() { if( AppRpc_TryInvokeAsync( &Pcsx2App::OpenMainFrame ) ) return;

if( GetMainFramePtr() != NULL ) return;

MainEmuFrame* mainFrame = new MainEmuFrame( NULL, pxGetAppName() );

... } </source>

Here we're creating an instance of the MainEmuFrame class. That class contains members for all the cool GUI elements, buttons, menus, stuff like that. So let's take a step further. Suppose we want to boot up a game. When we select Boot DVD in the pcsx2 menus, we are calling upon this function here:

in MainMenuClicks.cpp <source lang="cpp"> void MainEmuFrame::_DoBootCdvd() </source>

Into The Core

OK, this is where things start to get a little complicated. PCSX2 is basically divided up into a few different parts:

SysExecutor

Handles the virtual machine

EE Thread

(See BiosDebugData.h) Handles the Emotion Engine instructions.