PCSX2 Documentation/The PCSX2 Program Flow

From PCSX2 Wiki
Revision as of 20:49, 25 February 2015 by Krysto (talk | contribs)
Jump to navigation Jump to search

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

So where does Pcsx2App live? Well, the declarations are in the header file App.h and the definitions are in a few different files. But let's first take a look at this line in the header file: <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 the OnInit() method which is defined in AppInit.cpp. There's all kinds of crazy stuff happening here, but what we really care about is this line: <source lang="cpp"> if( m_UseGUI ) OpenMainFrame(); </source> In addition to Application classes, there are also Frame classes. The frame classes define the different windows in the GUI, and inside the frame classes are the various GUI parts that we can click on and interact with. This is opening the main pcsx2 window, which is declared in this header file: MainFrame.h. Take a look and you can see declarations for all the PCSX2 buttons and menus and all of that cool stuff!